Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
 public void Cancel_Not_Existing_Task()
 {
     TasksHost.Cancel(Guid.NewGuid());
 }