public void Send() { var channel = new StreamRpcChannel(controller.Object, readStream, writeStream); channel.Start(); channel.Send(testMessage); channel.CloseAndJoin(false); writeStream.Seek(0, SeekOrigin.Begin); var receivedMessage = Serializer.DeserializeWithLengthPrefix<RpcMessage>(writeStream, PrefixStyle.Fixed32); Assert.That(receivedMessage.IsEquivalentTo(testMessage), Is.True); }
public void Send() { var channel = new StreamRpcChannel(controller.Object, readStream, writeStream); channel.Start(); channel.Send(testMessage); channel.CloseAndJoin(false); writeStream.Seek(0, SeekOrigin.Begin); var receivedMessage = Serializer.DeserializeWithLengthPrefix <RpcMessage>(writeStream, PrefixStyle.Fixed32); Assert.That(receivedMessage.IsEquivalentTo(testMessage), Is.True); }
public void Receive() { Serializer.SerializeWithLengthPrefix(readStream, testMessage, PrefixStyle.Fixed32); readStream.Seek(0, SeekOrigin.Begin); ManualResetEvent doneEvent = new ManualResetEvent(false); controller.Setup(c => c.Receive(It.Is<RpcMessage>(m => m.IsEquivalentTo(testMessage)))) .Callback(() => doneEvent.Set()); var channel = new StreamRpcChannel(controller.Object, readStream, writeStream); channel.Start(); doneEvent.WaitOne(2000); channel.CloseAndJoin(); controller.VerifyAll(); }
public void Receive() { Serializer.SerializeWithLengthPrefix(readStream, testMessage, PrefixStyle.Fixed32); readStream.Seek(0, SeekOrigin.Begin); ManualResetEvent doneEvent = new ManualResetEvent(false); controller.Setup(c => c.Receive(It.Is <RpcMessage>(m => m.IsEquivalentTo(testMessage)))) .Callback(() => doneEvent.Set()); var channel = new StreamRpcChannel(controller.Object, readStream, writeStream); channel.Start(); doneEvent.WaitOne(2000); channel.CloseAndJoin(); controller.VerifyAll(); }
public void EndProcess(bool releaseMutex = true) { lock (this) { Console.WriteLine("Remote: Ending process: {0}, {1}-{2} (release:{3})", pipeName, Process.GetCurrentProcess().Id, Thread.CurrentThread.ManagedThreadId, releaseMutex); if (channel != null) { channel.CloseAndJoin(true, false); //do not wait for the closing; may hang?? } if (releaseMutex) { if (owningThread != Thread.CurrentThread.ManagedThreadId) { throw new InvalidOperationException( "You must remove the remote instance from the same thread you created it on"); } if (ourMutex != null) { ourMutex.ReleaseMutex(); ourMutex = null; } } if (process == null) { return; } try { process.Kill(); } catch (Exception) { } process = null; } }