9.3.9. Пример интеграции службы RobotNET Proxy

sdk\c-sharp\proxy\proxy\Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using RobotNET.SDK;

namespace RoboProxy
{
    class Program
    {
        static void Main( string[] args )
        {
            Console.WriteLine( string.Format( "Program started!" ) );

            if( args.Count() > 0 )
            {
                string proxymap = args[0];

                try
                {
                    using( Proxy proxy = new Proxy( proxymap, uint.MaxValue ) )
                    {
                        proxy.ProxyIt();

                        Console.WriteLine( "Proxy activated... To stop application press any key..." );

                        int state = 0, last = int.MaxValue;
                        while( !Console.KeyAvailable )
                        {
                            Int64 sx = 0, rx = 0, created = 0, deleted = 0, refused = 0;
                            state = proxy.ProxyCheck( ref sx, ref rx, ref created, ref deleted, ref refused );
                            if( state != last )
                                Console.WriteLine( "STATE: {0}", state == 0 ? "IDLE" : "OK" );
                            last = state;

                            System.Threading.Thread.Sleep( 1000 );
                        }

                        Console.WriteLine( "Proxy deactivated." );
                    }
                }
                catch( Exception e )
                {
                    Console.WriteLine( e.ToString() );
                }
            }

            Console.WriteLine( string.Format( "Program finished!" ) );
        }
    }
}