protected abstract TryExecuteTaskInline ( System.Threading.Tasks.Task task, bool taskWasPreviouslyQueued ) : bool | ||
task | System.Threading.Tasks.Task | |
taskWasPreviouslyQueued | bool | |
return | bool |
private bool PrivateStart(TaskScheduler scheduler, bool inline, bool throwSchedulerExceptions) { Scheduler = scheduler; var result = Interlocked.CompareExchange(ref _status, (int)TaskStatus.WaitingForActivation, (int)TaskStatus.Created); if (result != (int)TaskStatus.Created && result != (int)TaskStatus.WaitingForActivation) { return false; } var didInline = false; try { if (inline) { didInline = scheduler.TryExecuteTaskInline(this, IsScheduled); } if (!didInline) { scheduler.QueueTask(this); Interlocked.CompareExchange(ref _status, (int)TaskStatus.WaitingToRun, (int)TaskStatus.WaitingForActivation); } else { PrivateWait(CancellationToken, false); } } catch (ThreadAbortException exception) { if (!didInline) { AddException(exception); FinishThreadAbortedTask(true, false); } } catch (Exception exception) { var taskSchedulerException = new TaskSchedulerException(exception); RecordException(taskSchedulerException); if (throwSchedulerExceptions) { throw taskSchedulerException; } } return true; }