Exemplo n.º 1
0
        public void Stop()
        {
            if (!IsRunning)
            {
                return;
            }

            IsRunning = false;

            _dispatchBlock?.Cancel();
        }
Exemplo n.º 2
0
        public void Cancellation()
        {
            var called   = false;
            var callback = new Action(() => called = true);

            using (var db = new DispatchBlock(callback)) {
                Assert.AreEqual(0, db.TestCancel(), "TestCancel 1");
                Assert.IsFalse(db.Cancelled, "Cancelled 1");
                db.Cancel();
                Assert.AreNotEqual(0, db.TestCancel(), "TestCancel 2");
                Assert.IsTrue(db.Cancelled, "Cancelled 2");
            }
        }