public GateKeeperReadyProcessor(IDataStorage <GateKeeperBot> dataStorage, AsyncTaskExecutor asyncTaskExecutor, IUserChecker userChecker, IMessagesSender messagesSender)
 {
     this.dataStorage       = dataStorage;
     this.asyncTaskExecutor = asyncTaskExecutor;
     this.userChecker       = userChecker;
     this.messagesSender    = messagesSender;
 }
Пример #2
0
        public void Test_01_Init()
        {
            var executor = new AsyncTaskExecutor(TaskName, ExecuteAsync);

            Assert.That(executor.TaskName == TaskName);
            Assert.That(executor.IsBusy == false);
            Assert.That(executor.BusyStatus == null);
            Assert.That(executor.Status == AsyncTaskExecutionStatus.WaitForActivation);
        }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
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 + "...");
        }
Пример #6
0
 public SearchReadyProcessor(IServiceProvider serviceProvider, IMessagesSender messagesSender, AsyncTaskExecutor asyncTaskExecutor)
 {
     this.messagesSender    = messagesSender;
     this.serviceProvider   = serviceProvider;
     this.asyncTaskExecutor = asyncTaskExecutor;
 }
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="executor"></param>
 public AsyncTaskExtension(AsyncTaskExecutor executor = null)
 {
     this.executor = executor;
 }
Пример #8
0
 public AsyncTaskContext()
 {
     progress     = new ProgressInfo();
     taskExecutor = new AsyncTaskExecutor(this);
 }