public TaskInfo(MasterTaskType type, TaskCompletion result, TaskId taskid, User user) { this.type = type; this.result = result; this.taskid = taskid; this.user = user; }
private async Task StartInternal(CancellationToken cancellationToken) { try { while (true) { cancellationToken.ThrowIfCancellationRequested(); var result = Dequeue(); if (result != null) { _outputStream.Write(result.Item1, result.Item2, result.Item3); } else { await Task.Delay(50, cancellationToken).ConfigureAwait(false); } } } catch (OperationCanceledException) { _logger.Debug("QueueStream cancelled"); TaskCompletion.TrySetCanceled(); } catch (Exception ex) { _logger.ErrorException("Error in QueueStream", ex); TaskCompletion.TrySetException(ex); } finally { OnClosed(); } }
void ITaskCallback.OnComplete(TaskCompletion result) { completionSource.TrySetResult(result); if (proxy != null) { proxy.OnComplete(result); } }
public async Task RePlayAsync() { if (TaskCompletion != null) { await TaskCompletion.ConfigureAwait(false); } TriggerTask(); }
/// <summary> /// Completes a task (verb run). /// </summary> /// <remarks> /// Note that for Async verb workers, this method runs on a separate thread. /// </remarks> /// <param name="verb">The verb which was run.</param> /// <param name="worker">The verb's worker.</param> private void completeTask(IVerb verb, IVerbWorker worker) { this.taskCompletionsLock.AcquireWriterLock(Timeout.Infinite); Disposition disp = worker.Complete(); TaskCompletion tc = new TaskCompletion(worker.GetWorkingDirectory(), verb, disp); this.taskCompletions.Add(tc); this.completionEvent.Set(); this.taskCompletionsLock.ReleaseWriterLock(); }
public static void Explain(this TaskCompletion runnable, TextWriter writer) { writer.WriteLine(@" - `TaskCompletionSource<TResult>` is a handy tool to achieve complex interop and custom async scenarios - It represents a custom task that can be controled and transitioned into the state you like - Attention: Awaiter completes on thread that called `SetResult` or `TrySetResult` - Use `TaskCompletionSource<TResult>(TaskCreationOptions.RunContinuationsAsynchronously)` with .NET 4.6.2 or higher to opt-out from sync completion. "); }
void completeTask(IVerb verb, IVerbWorker worker) { taskCompletionsLock.AcquireWriterLock(Timeout.Infinite); Disposition disp = worker.complete(); TaskCompletion tc = new TaskCompletion(verb, disp); taskCompletions.Add(tc); completionEvent.Set(); taskCompletionsLock.ReleaseWriterLock(); }
public BeginUpdateKeyChangeResult( TaskCompletion result, User user, System.UInt32 keyChangeSequenceNum, byte[] masterChallengeData, byte[] outstationChallengeData ) { this.result = result; this.user = user; this.keyChangeSequenceNum = keyChangeSequenceNum; this.masterChallengeData = masterChallengeData; this.outstationChallengeData = outstationChallengeData; }
private async Task StartInternal() { var cancellationToken = _cancellationToken; try { while (!cancellationToken.IsCancellationRequested) { _isActive = true; var bytes = Dequeue(); if (bytes != null) { await _outputStream.WriteAsync(bytes, 0, bytes.Length, cancellationToken).ConfigureAwait(false); } else { await Task.Delay(50, cancellationToken).ConfigureAwait(false); } } TaskCompletion.TrySetResult(true); _logger.Debug("QueueStream complete"); } catch (OperationCanceledException) { _logger.Debug("QueueStream cancelled"); TaskCompletion.TrySetCanceled(); } catch (Exception ex) { _logger.ErrorException("Error in QueueStream", ex); TaskCompletion.TrySetException(ex); } finally { _isActive = false; if (OnFinished != null) { OnFinished(this); } } }
public void Write(byte[] bytes, int offset, int count) { //return _outputStream.WriteAsync(bytes, offset, count, cancellationToken); try { _outputStream.Write(bytes, offset, count); } catch (OperationCanceledException) { _logger.Debug("QueueStream cancelled"); TaskCompletion.TrySetCanceled(); OnClosed(); } catch (Exception ex) { _logger.ErrorException("Error in QueueStream", ex); TaskCompletion.TrySetException(ex); OnClosed(); } }
public async Task ExecuteJob() { TRequest request; if (Dependencies != null && Dependencies.Count > 0) { var tasks = Dependencies.Select(y => y.WaitOn).ToArray(); var responses = await Task.WhenAll(tasks); request = Initialize(responses); } else { request = Initialize(null); } var med = new Mediator(); Response = await med.Send <TRequest, TResponse>(request); TaskCompletion.SetResult(Response); }
public async Task WriteAsync(byte[] bytes, int offset, int count) { //return _outputStream.WriteAsync(bytes, offset, count, cancellationToken); var cancellationToken = _cancellationToken; try { await _outputStream.WriteAsync(bytes, offset, count, cancellationToken).ConfigureAwait(false); } catch (OperationCanceledException) { _logger.Debug("QueueStream cancelled"); TaskCompletion.TrySetCanceled(); OnClosed(); } catch (Exception ex) { _logger.ErrorException("Error in QueueStream", ex); TaskCompletion.TrySetException(ex); OnClosed(); } }
protected void addTask_OnClick(object sender, EventArgs e) { //var checkDate = CheckPreviousDate(dueDate.Text); //if (checkDate) //{ // lblError.Visible = true; // return; //} //lblError.Visible = false; var taskDescription = taskDesciption.Text; var id = Convert.ToInt64(Session["ID"]); var taskDoc = new TaskDocument(); var stats = 0; var selectedUserId = Convert.ToInt32(userList.SelectedValue); if (attachments.HasFile) { var files = attachments.PostedFiles; foreach (var file in files) { var fileName = Page.Server.MapPath("~/Uploads/TaskDocuments/" + Path.GetFileName(file.FileName)); file.SaveAs(fileName); var fileByte = _imageService.ReadToEnd(file.InputStream); taskDoc = _insedlu.TaskDocuments.Add( new TaskDocument { name = fileName, created_at = DateTime.Today, file = fileByte }); try { _insedlu.SaveChanges(); } catch (DbEntityValidationException exception) { Console.WriteLine(exception.EntityValidationErrors); throw; } } } if (!string.IsNullOrEmpty(taskDescription)) { var date = DateTime.ParseExact(dueDate.Text, "dd/MM/yyyy", null); var todaysDate = DateTime.Today; var numberOfDays = GetRemainingDays(date, todaysDate); var task = new Task { created_at = DateTime.Now, body = taskDescription, modified_at = DateTime.Now, due_date = date, user_id = (int)id, status = (int)TaskStatus.Assigned, task_document_id = taskDoc.id, number_of_days_left = numberOfDays }; myTasksList.Text = task.body; var check = _projectService.SaveTask(task); var taskComplete = new TaskCompletion { completion = numberOfDays.ToString(), task_id = (int)task.id }; _insedlu.TaskCompletions.Add(taskComplete); _insedlu.SaveChanges(); stats = Status("Assigned"); var taskStatus = Convert.ToInt32(stats); //var task = _insedlu.Tasks.Single(x => x.id == taskId); task.status = taskStatus; task.assigned_to = selectedUserId; _insedlu.Entry(task).State = EntityState.Modified; _insedlu.SaveChanges(); if (check == 1) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "alert", "alert('Task saved successfully')", true); } } SetTasks(_id); }
public TaskInfo(MasterTaskType type, TaskCompletion result, TaskId taskid) { this.type = type; this.result = result; this.taskid = taskid; }
/// <summary> /// Completes a task (verb run). /// </summary> /// <remarks> /// Note that for Async verb workers, this method runs on a separate thread. /// </remarks> /// <param name="verb">The verb which was run.</param> /// <param name="worker">The verb's worker.</param> private void completeTask(IVerb verb, IVerbWorker worker) { this.taskCompletionsLock.AcquireWriterLock(Timeout.Infinite); Disposition disp = worker.Complete(); TaskCompletion tc = new TaskCompletion(worker.GetWorkingDirectory(), verb, disp); this.taskCompletions.Add(tc); this.completionEvent.Set(); this.taskCompletionsLock.ReleaseWriterLock(); }
/// <summary> /// Initializes a new instance of the <see cref="TaskCompletionEventArgs"/> class /// </summary> /// <param name="completion">The completion state</param> public TaskCompletionEventArgs(TaskCompletion completion) { Completion = completion; }
void ITaskCallback.OnComplete(TaskCompletion result) { tcs.SetResult(result); }
public static void PrintEnd(this TaskCompletion runnable) { Console.WriteLine($"Continue on {Thread.CurrentThread.ManagedThreadId}"); }
void ITaskCallback.OnComplete(TaskCompletion result) { tcs.SetResult(result); }
public void OnComplete(TaskCompletion result) { tcs.SetResult(result); }
public CommandResponse(TaskCompletion result, CommandStatus status) { this.result = result; this.status = status; }
public static void PrintStart(this TaskCompletion runnable) { Console.WriteLine($"Start on {Thread.CurrentThread.ManagedThreadId}"); }
public RestartResultType(TaskCompletion summary, TimeSpan restartTime) { this.summary = summary; this.restartTime = restartTime; }
void IMasterApplication.OnTaskComplete(MasterTaskType type, TaskCompletion result, int userId) { // ignore these in the default application }
public CommandTaskResult(TaskCompletion summary, IEnumerable <CommandPointResult> results) { this.summary = summary; this.results = results; }