public void Stop() { try { cancel(); #if UseTask // // Block GUI requested stops briefly, allowing the search // statistics to be written before this request completes. // const Int32 stopTimeoutMS = 5000; if (CancelTimer is not null) { CancelTimer.Change(stopTimeoutMS, Timeout.Infinite); } FinishTask?.Wait(); // //[Note]The old CancellationToken must be recycled after cancel() has been called. // freeCancellationToken(); #endif } catch (AggregateException aex) { var ex = aex.Flatten(); //LogLine(ex.ToString()); throw ex; } }
public async Task <IActionResult> Put([FromRoute] Guid taskId, [FromBody] FinishTask command) { command.TaskId = taskId; await CommandDispatcher.DispatchAsync(command); return(NoContent()); }
public void Finish() { lock (DoubleBuffer) { if (!_isDoing) { FinishTask.SetResult(true); return; } Finished += (sender, args) => FinishTask.SetResult(true); } }
public void Sync() { StartTask?.GetAwaiter().GetResult(); FinishTask?.GetAwaiter().GetResult(); }