public void Enqueue_And_Cancel() { var mre = new ManualResetEvent(false); var key = Guid.NewGuid(); var parameter = new Dictionary <string, object>(); parameter.Add("count", 0); TasksHost.Enqueue <LongTask>(key, parameter, completed: (dic) => { mre.Set(); }); System.Threading.Thread.Sleep(2 * 1000); TasksHost.Cancel(key); mre.WaitOne(); var history = TasksHost.GetHistory(key); Check.That(history.CanceledDate).IsNotNull(); var count = history.Parameters["count"]; Check.That((int)count).IsLessThan(10); }
public void Cancel_Terminated_Task() { var id = Guid.NewGuid(); var mre = new ManualResetEvent(false); TasksHost.Enqueue <MyTask>(id, completed: (dic) => { mre.Set(); }); mre.WaitOne(); TasksHost.Cancel(id); }
public void Cancel_Not_Existing_Task() { TasksHost.Cancel(Guid.NewGuid()); }