public void CanAbort( ) { int i = 0; ActionTask a = new ActionTask((task) => i = 1, false); a.Abort(); Assert.IsTrue(a.Aborted, "Task doesn't think it was aborted."); ActionTask b = new ActionTask((task) => { i = 2; task.Abort(); }, false); b.Extend((task) => { if (!task.Aborted) { i = 3; } }); (b as ITask).Start(); Assert.IsTrue(b.Aborted, "Task doesn't think it was aborted after continuation."); Assert.IsTrue(b.IsCompleted, "Task thinks it didn't complete after abortion."); Assert.AreEqual(2, i, "Task's aborted flag didn't set correctly."); }
public void CanAbort( ) { int i = 0; ActionTask a = new ActionTask(( task ) => i = 1, false); a.Abort(); Assert.IsTrue(a.Aborted, "Task doesn't think it was aborted."); ActionTask b = new ActionTask(( task ) => { i = 2; task.Abort(); }, false); b.Extend(( task ) => { if ( !task.Aborted ) i = 3; }); (b as ITask).Start(); Assert.IsTrue(b.Aborted, "Task doesn't think it was aborted after continuation."); Assert.IsTrue(b.IsCompleted, "Task thinks it didn't complete after abortion."); Assert.AreEqual(2, i, "Task's aborted flag didn't set correctly."); }