コード例 #1
0
 public object Call(MessageContract contract)
 {
     if (_client.SendAsync(contract).Wait(ConfigurableTimeout))
     {
         return(_client.ReceiveAsync().Result);
     }
     throw new Exception(string.Format("Error invoking {0} remote service method.", contract.MethodName));
 }
コード例 #2
0
    static void Main(string[] args)
    {
        var server = new ChannelTcpListener();

        server.MessageReceived = OnServerReceivedMessage;
        server.Start(IPAddress.Any, 0);

        var client = new ChannelTcpClient <object>(new MicroMessageEncoder(new DataContractMessageSerializer()),
                                                   new MicroMessageDecoder(new DataContractMessageSerializer()));

        client.ConnectAsync(IPAddress.Loopback, server.LocalPort).Wait();
        client.SendAsync(new FileStream("TextSample.txt", FileMode.Open)).Wait();


        Console.ReadLine();
    }
コード例 #3
0
        public async Task ExecuteAsync <T>(T command) where T : Command
        {
            await EnsureConnected();

            try
            {
                var waiter = new Waiter <T>(command.CommandId);
                _response[command.CommandId] = waiter;
                await _client.SendAsync(command);

                await waiter.Task;
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #4
0
 private Task SendItem(object item)
 {
     _lastSentItem = item;
     return(_client.SendAsync(item));
 }