Пример #1
0
        public async Task Test_02_Execute()
        {
            IAsyncTaskExecutor executor = new AsyncTaskExecutor(TaskName, ExecuteAsync);
            var task = executor.ExecuteTask(null);

            Assert.That(executor.IsBusy);
            Assert.That(executor.BusyStatus == TaskName + "...");
            await task;

            Assert.That(executor.IsBusy == false);
            Assert.That(executor.BusyStatus == null);
        }
Пример #2
0
        public async Task Test_02_Cancel()
        {
            IAsyncTaskExecutor executor = new AsyncTaskExecutor(TaskName, ExecuteTimeConsumingAsync);
            var task = executor.ExecuteTask(null);

            Assert.That(executor.IsBusy);
            Assert.That(executor.BusyStatus == TaskName + "...");

            await Task.Delay(10);

            executor.CancelTask();
            await task;

            Assert.That(executor.IsBusy == false);
            Assert.That(executor.BusyStatus == null);
        }
Пример #3
0
        public async Task Test_03_PauseResume()
        {
            IAsyncTaskExecutor executor = new AsyncTaskExecutor(TaskName, ExecuteTimeConsumingAsync);
            var task = executor.ExecuteTask(null);

            Assert.That(executor.IsBusy);
            Assert.That(executor.BusyStatus == TaskName + "...");

            await Task.Delay(10);

            executor.PauseTask();
            Assert.That(executor.Status == AsyncTaskExecutionStatus.Paused);
            Assert.That(executor.IsBusy);
            Assert.That(executor.BusyStatus == TaskName + "...");

            executor.ResumeTask();
            Assert.That(executor.Status == AsyncTaskExecutionStatus.Resumed);
            Assert.That(executor.IsBusy);
            Assert.That(executor.BusyStatus == TaskName + "...");
        }