Пример #1
0
        public static async void TesteChannel()
        {
            Server server = new Server();

            var serverPort = new ServerPort("127.0.0.1", P_PORTA_RPC, ServerCredentials.Insecure);

            server.Ports.Add(serverPort);

            var searchService = SearchService.BindService(new MyService());

            server.Services.Add(searchService);
            server.Start();

            Channel channel = new Channel("localhost", P_PORTA_RPC, ChannelCredentials.Insecure);

            channel.ConnectAsync(DateTime.UtcNow.AddSeconds(4)).Wait();
            var client = new SearchServiceClient(channel);

            SearchRequest req = new SearchRequest();

            req.FileMask     = "*.bat";
            req.StartDir     = @"C:\";
            req.Recursive    = true;
            req.IgnoreErrors = true;
            var result = client.Search(req);

            Debug.WriteLine("[p1]");

            var t1 = client.Delay1Async(new DelayDesc()
            {
                MilliSeconds = 2000
            });

            Debug.WriteLine("[p2]");

            Debug.WriteLine("[p3]");

            var t2 = client.Delay2Async(new DelayDesc()
            {
                MilliSeconds = 1000
            });

            Debug.WriteLine("[p4]");

            Empty v1 = await t1;

            Debug.WriteLine("[p5]");

            Empty v2 = await t2;

            Debug.WriteLine("[p6]");

            ProcessStartInfoPB psi = new ProcessStartInfoPB();

            psi.FileName = "c:/temp/teste.bat";
            var p = client.RunCmd(psi);
        }