protected void RunCallback(ContextCallback callback, object state, ref Task currentTask) { Task task = currentTask; try { if (task != null) { currentTask = (Task)null; } if (this.m_capturedContext == null) { callback(state); } else { ExecutionContext.Run(this.m_capturedContext, callback, state, true); } } catch (Exception ex) { AwaitTaskContinuation.ThrowAsyncIfNecessary(ex); } finally { if (task != null) { currentTask = task; } if (this.m_capturedContext != null) { this.m_capturedContext.Dispose(); } } }
internal static void RunOrScheduleAction(Action action, bool allowInlining, ref Task currentTask) { if (!allowInlining || !AwaitTaskContinuation.IsValidLocationForInlining) { AwaitTaskContinuation.UnsafeScheduleAction(action, currentTask); } else { Task task = currentTask; try { if (task != null) { currentTask = (Task)null; } action(); } catch (Exception ex) { AwaitTaskContinuation.ThrowAsyncIfNecessary(ex); } finally { if (task != null) { currentTask = task; } } } }
// Token: 0x0600405C RID: 16476 RVA: 0x000EFE3C File Offset: 0x000EE03C internal sealed override void Run(Task ignored, bool canInlineContinuationTask) { if (this.m_scheduler == TaskScheduler.Default) { base.Run(ignored, canInlineContinuationTask); return; } bool flag = canInlineContinuationTask && (TaskScheduler.InternalCurrent == this.m_scheduler || Thread.CurrentThread.IsThreadPoolThread); Task task = base.CreateTask(delegate(object state) { try { ((Action)state)(); } catch (Exception exc) { AwaitTaskContinuation.ThrowAsyncIfNecessary(exc); } }, this.m_action, this.m_scheduler); if (flag) { TaskContinuation.InlineIfPossibleOrElseQueue(task, false); return; } try { task.ScheduleAndStart(false); } catch (TaskSchedulerException) { } }
internal override sealed void Run(Task ignored, bool canInlineContinuationTask) { if (this.m_scheduler == TaskScheduler.Default) { base.Run(ignored, canInlineContinuationTask); } else { int num = !canInlineContinuationTask ? 0 : (TaskScheduler.InternalCurrent == this.m_scheduler ? 1 : (Thread.CurrentThread.IsThreadPoolThread ? 1 : 0)); Task task = this.CreateTask((Action <object>)(state => { try { ((Action)state)(); } catch (Exception ex) { AwaitTaskContinuation.ThrowAsyncIfNecessary(ex); } }), (object)this.m_action, this.m_scheduler); if (num != 0) { TaskContinuation.InlineIfPossibleOrElseQueue(task, false); } else { try { task.ScheduleAndStart(false); } catch (TaskSchedulerException ex) { } } } }