Exemple #1
0
        public void RunAsync(TypedRequest request, Action <TypedResponse> callback, Action <ErrorResponse> errorCallback)
        {
            var sw = Stopwatch.StartNew();

            var ipcRequest = new IpcRequest {
                RequestId = _ipcRequestIdFactory.GetNextId(),
                Protocol  = IpcProtocols.TypedMessage,
                Data      = request
            };

            // Note: We capture the value outside the RunAsync callback.
            var localSequenceNumber = Interlocked.Increment(ref _currentSequenceNumber);

            _serverProcessProxy.RunAsync(ipcRequest, ipcResponse => {
                lock (_lock) {
                    _bufferedResponses.Add(new BufferedResponse {
                        SequenceNumber  = localSequenceNumber,
                        IpcRequest      = ipcRequest,
                        IpcResponse     = ipcResponse,
                        SuccessCallback = callback,
                        ErrorCallback   = errorCallback,
                        Elapsed         = sw.Elapsed
                    });
                }
                OnResponseReceived();
            });
        }
        public void SendEventAsync(TypedEvent typedEvent)
        {
            var ipcEvent = new IpcEvent {
                RequestId = _requestIdFactory.GetNextId(),
                Protocol  = IpcProtocols.TypedMessage,
                Data      = typedEvent
            };

            _responseQueue.Enqueue(ipcEvent);
        }
Exemple #3
0
        public void RunAsyncWorker(TypedRequest request, Action <TypedResponse> successCallback,
                                   Action <ErrorResponse> errorCallback, long sequenceNumber, Action <BufferedResponse> processResponse)
        {
            var sw = Stopwatch.StartNew();

            var ipcRequest = new IpcRequest {
                RequestId = _ipcRequestIdFactory.GetNextId(),
                Protocol  = IpcProtocols.TypedMessage,
                Data      = request
            };

            _serverProcessProxy.RunAsync(ipcRequest, ipcResponse => {
                var response = new BufferedResponse {
                    SequenceNumber  = sequenceNumber,
                    IpcRequest      = ipcRequest,
                    IpcResponse     = ipcResponse,
                    SuccessCallback = successCallback,
                    ErrorCallback   = errorCallback,
                    Elapsed         = sw.Elapsed
                };
                processResponse(response);
            });
        }