Esempio n. 1
0
        public async Task WriteStreamAsync(PipeMessageByteCode code, int command = 0, bool waitForConnect = true)
        {
            DebugTrace("TestService " + ServiceName + ": WriteStreamAsync writing " + code.ToString());

            var toWrite = (code == PipeMessageByteCode.OnCustomCommand) ? new byte[] { (byte)command } : new byte[] { (byte)code };

            // Wait for the client connection before writing to the pipe.
            if (waitForConnect)
            {
                await _waitClientConnect;
            }
            await _serverStream.WriteAsync(toWrite, 0, 1).WaitAsync(TimeSpan.FromSeconds(60)).ConfigureAwait(false);

            DebugTrace("TestService " + ServiceName + ": WriteStreamAsync completed");
        }
Esempio n. 2
0
        public async Task WriteStreamAsync(PipeMessageByteCode code, int command = 0)
        {
            DebugTrace("TestService " + ServiceName + ": WriteStreamAsync writing " + code.ToString());

            const int WriteTimeout = 60000;
            var       toWrite      = (code == PipeMessageByteCode.OnCustomCommand) ? new byte[] { (byte)command } : new byte[] { (byte)code };

            // Wait for the client connection before writing to the pipe.
            // Exception: if it's a Stop message, it may be because the test has completed and we're cleaning up the test service so there's no client at all.
            // Tests that verify "Stop" itself should ensure the client connection has completed before calling stop, by waiting on some other message from the pipe first.
            if (code != PipeMessageByteCode.Stop)
            {
                await _waitClientConnect;
            }
            await _serverStream.WriteAsync(toWrite, 0, 1).TimeoutAfter(WriteTimeout).ConfigureAwait(false);

            DebugTrace("TestService " + ServiceName + ": WriteStreamAsync completed");
        }