예제 #1
0
 public R Request(S obj)
 {
     using (var client = new NamedPipeClientStream(ServerName, PipeName))
     {
         client.Connect();
         Formatter.Serialize(client, obj);
         OnRequestSended?.Invoke(this, obj);
         var response = Formatter.Deserialize <R>(client);
         OnResponseReceived?.Invoke(this, response);
         return(response);
     }
 }
예제 #2
0
        public async Task <R> RequestAsync(S obj, CancellationToken cancellationToken)
        {
            using (var client = new NamedPipeClientStream(ServerName, PipeName))
            {
                await client.ConnectAsync(cancellationToken);

                Formatter.Serialize(client, obj);
                OnRequestSended?.Invoke(this, obj);
                var response = Formatter.Deserialize <R>(client);
                OnResponseReceived?.Invoke(this, response);
                return(response);
            }
        }