示例#1
0
        public void TestSetBeforeGet()
        {
            var k = new BlockingCell <int>();

            k.ContinueWithValue(123);
            Assert.AreEqual(123, k.WaitForValue());
        }
示例#2
0
        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);
        }
示例#3
0
 public virtual void HandleCommand(Command cmd)
 {
     m_cell.ContinueWithValue(Either <Command, ShutdownEventArgs> .Left(cmd));
 }
示例#4
0
 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);
        }