public void TestSetBeforeGet() { var k = new BlockingCell <int>(); k.ContinueWithValue(123); Assert.AreEqual(123, k.WaitForValue()); }
public void TestGetValueWhichDoesNotTimeOut() { var k = new BlockingCell <int>(); k.ContinueWithValue(123); ResetTimer(); var v = k.WaitForValue(TimingInterval); Assert.Greater(SafetyMargin, ElapsedMs()); Assert.AreEqual(123, v); }
public virtual void HandleCommand(Command cmd) { m_cell.ContinueWithValue(Either <Command, ShutdownEventArgs> .Left(cmd)); }
public void Run() { Thread.Sleep(m_delayMs); m_k.ContinueWithValue(m_v); }
// You will note there are two practically identical overloads // of OnShutdown() here. This is because Microsoft's C# // compilers do not consistently support the Liskov // substitutability principle. When I use // OnShutdown(object,ShutdownEventArgs), the compilers // complain that OnShutdown can't be placed into a // ConnectionShutdownEventHandler because object doesn't // "match" IConnection, even though there's no context in // which the program could Go Wrong were it to accept the // code. The same problem appears for // ModelShutdownEventHandler. The .NET 1.1 compiler complains // about these two cases, and the .NET 2.0 compiler does not - // presumably they improved the type checker with the new // release of the compiler. public virtual void OnConnectionShutdown(object sender, ShutdownEventArgs reason) { m_cell.ContinueWithValue(reason); }