public void SingleConsumerWithException() { var failed = new List <Exception>(); var exec = new ExceptionHandlingExecutor(failed.Add); using (IFiber one = PoolFiber.StartNew(exec)) using (var reset = new AutoResetEvent(false)) { var channel = new QueueChannel <int>(); void OnMsg(int num) { if (num == 0) { throw new Exception(); } reset.Set(); } channel.Subscribe(one, OnMsg); channel.Publish(0); channel.Publish(1); Assert.IsTrue(reset.WaitOne(10000, false)); Assert.AreEqual(1, failed.Count); } }
public void ExceptionHandlingExecutor() { using AutoResetEvent reset = new AutoResetEvent(false); ExceptionHandlingExecutor h = new ExceptionHandlingExecutor(x => reset.Set()); h.Execute(() => throw new Exception()); Assert.IsTrue(reset.WaitOne(100)); }
public void SingleConsumerWithException() { var failed = new List<Exception>(); var exec = new ExceptionHandlingExecutor(failed.Add); using (IFiber one = PoolFiber.StartNew(exec)) using (var reset = new AutoResetEvent(false)) { var channel = new QueueChannel<int>(); Action<int> onMsg = num => { if (num == 0) throw new Exception(); reset.Set(); }; channel.Subscribe(one, onMsg); channel.Publish(0); channel.Publish(1); Assert.IsTrue(reset.WaitOne(10000, false)); Assert.AreEqual(1, failed.Count); } }