34 fromAsyncTrimPromise.m_thisRef =
null;
35 fromAsyncTrimPromise.m_endMethod =
null;
97 return currTask.ExecutingTaskScheduler;
227 promise.DangerousSetResult(result);
346 if (!
iar.CompletedSynchronously)
348 FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
406 if (!
iar.CompletedSynchronously)
408 FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
432 public Task<TResult> FromAsync<TArg1, TArg2>(
Func<TArg1, TArg2, AsyncCallback, object?, IAsyncResult> beginMethod,
Func<IAsyncResult, TResult> endMethod, TArg1
arg1, TArg2
arg2,
object? state)
437 public Task<TResult> FromAsync<TArg1, TArg2>(
Func<TArg1, TArg2, AsyncCallback, object?, IAsyncResult> beginMethod,
Func<IAsyncResult, TResult> endMethod, TArg1
arg1, TArg2
arg2,
object? state,
TaskCreationOptions creationOptions)
442 internal static Task<TResult> FromAsyncImpl<TArg1, TArg2>(
Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult> beginMethod,
Func<IAsyncResult, TResult> endFunction,
Action<IAsyncResult> endAction, TArg1
arg1, TArg2
arg2,
object state,
TaskCreationOptions creationOptions)
466 if (!
iar.CompletedSynchronously)
468 FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
492 public Task<TResult> FromAsync<TArg1, TArg2, TArg3>(
Func<TArg1, TArg2, TArg3, AsyncCallback, object?, IAsyncResult> beginMethod,
Func<IAsyncResult, TResult> endMethod, TArg1
arg1, TArg2
arg2, TArg3
arg3,
object? state)
497 public Task<TResult> FromAsync<TArg1, TArg2, TArg3>(
Func<TArg1, TArg2, TArg3, AsyncCallback, object?, IAsyncResult> beginMethod,
Func<IAsyncResult, TResult> endMethod, TArg1
arg1, TArg2
arg2, TArg3
arg3,
object? state,
TaskCreationOptions creationOptions)
502 internal static Task<TResult> FromAsyncImpl<TArg1, TArg2, TArg3>(
Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult> beginMethod,
Func<IAsyncResult, TResult> endFunction,
Action<IAsyncResult> endAction, TArg1
arg1, TArg2
arg2, TArg3
arg3,
object state,
TaskCreationOptions creationOptions)
526 if (!
iar.CompletedSynchronously)
528 FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true);
552 internal static Task<TResult> FromAsyncTrim<TInstance, TArgs>(TInstance
thisRef,
TArgs args,
Func<TInstance, TArgs, AsyncCallback, object, IAsyncResult> beginMethod,
Func<TInstance, IAsyncResult, TResult> endMethod)
where TInstance :
class
575 return ContinueWhenAllImpl(
tasks,
continuationFunction,
null, m_defaultContinuationOptions, m_defaultCancellationToken, DefaultScheduler);
611 return ContinueWhenAllImpl(
tasks,
continuationFunction,
null, m_defaultContinuationOptions, m_defaultCancellationToken, DefaultScheduler);
704 return ContinueWhenAnyImpl(
tasks,
continuationFunction,
null, m_defaultContinuationOptions, m_defaultCancellationToken, DefaultScheduler);
740 return ContinueWhenAnyImpl(
tasks,
continuationFunction,
null, m_defaultContinuationOptions, m_defaultCancellationToken, DefaultScheduler);
777 if (
tasks.Length == 0)
808 if (
tasks.Length == 0)
828public class TaskFactory
830 private sealed class CompleteOnCountdownPromise :
Task<Task[]>, ITaskCompletionAction
836 public bool InvokeMayRunArbitraryCode =>
true;
838 private protected override bool ShouldNotifyDebuggerOfWaitCompletion
842 if (
base.ShouldNotifyDebuggerOfWaitCompletion)
872 SetNotificationForWaitCompletion(enabled:
true);
884 TrySetResult(_tasks);
895 public bool InvokeMayRunArbitraryCode =>
true;
897 private protected override bool ShouldNotifyDebuggerOfWaitCompletion
901 if (
base.ShouldNotifyDebuggerOfWaitCompletion)
932 SetNotificationForWaitCompletion(enabled:
true);
944 TrySetResult(_tasks);
955 public bool InvokeMayRunArbitraryCode => (_stateFlags & 2) == 0;
993 int count =
tasks.Count;
994 for (
int i = 0; i < count; i++)
997 if (
task !=
null && !
task.IsCompleted)
999 task.RemoveContinuation(
this);
1207 public Task FromAsync<TArg1, TArg2>(
Func<TArg1, TArg2, AsyncCallback, object?, IAsyncResult> beginMethod,
Action<IAsyncResult> endMethod, TArg1
arg1, TArg2
arg2,
object? state,
TaskCreationOptions creationOptions)
1212 public Task FromAsync<TArg1, TArg2, TArg3>(
Func<TArg1, TArg2, TArg3, AsyncCallback, object?, IAsyncResult> beginMethod,
Action<IAsyncResult> endMethod, TArg1
arg1, TArg2
arg2, TArg3
arg3,
object? state)
1217 public Task FromAsync<TArg1, TArg2, TArg3>(
Func<TArg1, TArg2, TArg3, AsyncCallback, object?, IAsyncResult> beginMethod,
Action<IAsyncResult> endMethod, TArg1
arg1, TArg2
arg2, TArg3
arg3,
object? state,
TaskCreationOptions creationOptions)
1257 public Task<TResult> FromAsync<TArg1, TArg2, TResult>(
Func<TArg1, TArg2, AsyncCallback, object?, IAsyncResult> beginMethod,
Func<IAsyncResult, TResult> endMethod, TArg1
arg1, TArg2
arg2,
object? state)
1262 public Task<TResult> FromAsync<TArg1, TArg2, TResult>(
Func<TArg1, TArg2, AsyncCallback, object?, IAsyncResult> beginMethod,
Func<IAsyncResult, TResult> endMethod, TArg1
arg1, TArg2
arg2,
object? state,
TaskCreationOptions creationOptions)
1267 public Task<TResult> FromAsync<TArg1, TArg2, TArg3, TResult>(
Func<TArg1, TArg2, TArg3, AsyncCallback, object?, IAsyncResult> beginMethod,
Func<IAsyncResult, TResult> endMethod, TArg1
arg1, TArg2
arg2, TArg3
arg3,
object? state)
1272 public Task<TResult> FromAsync<TArg1, TArg2, TArg3, TResult>(
Func<TArg1, TArg2, TArg3, AsyncCallback, object?, IAsyncResult> beginMethod,
Func<IAsyncResult, TResult> endMethod, TArg1
arg1, TArg2
arg2, TArg3
arg3,
object? state,
TaskCreationOptions creationOptions)
1299 for (
int i = 0; i <
tasksCopy.Length; i++)
1316 for (
int i = 0; i <
tasksCopy.Length; i++)
1478 int count =
tasks.Count;
1479 for (
int i = 0; i < count; i++)
1495 if (
task.IsCompleted)
1665 if (
tasks.Length == 0)
1670 for (
int i = 0; i <
tasks.Length; i++)
1673 if (
array[i] ==
null)
1687 if (
tasks.Length == 0)
1692 for (
int i = 0; i <
tasks.Length; i++)
1695 if (
array[i] ==
null)
static string Task_MultiTaskContinuation_EmptyTaskList
static string Task_FromAsync_PreferFairness
static string Task_MultiTaskContinuation_FireOptions
static string Task_FromAsync_LongRunning
static string Task_MultiTaskContinuation_NullTask
static string Task_ContinueWith_ESandLR
static int Exchange(ref int location1, int value)
static int Decrement(ref int location)
readonly Task< T >[] _tasks
void Invoke(Task completingTask)
CompleteOnCountdownPromise(Task< T >[] tasksCopy)
CompleteOnCountdownPromise(Task[] tasksCopy)
CompleteOnInvokePromise(IList< Task > tasks, bool isSyncBlocking)
void Invoke(Task completingTask)
void Complete(TInstance thisRef, Func< TInstance, IAsyncResult, TResult > endMethod, IAsyncResult asyncResult, bool requiresSynchronization)
static readonly AsyncCallback s_completeFromAsyncResult
Func< TInstance, IAsyncResult, TResult > m_endMethod
static void CompleteFromAsyncResult(IAsyncResult asyncResult)
FromAsyncTrimPromise(TInstance thisRef, Func< TInstance, IAsyncResult, TResult > endMethod)
Task< TResult > ContinueWhenAll(Task[] tasks, Func< Task[], TResult > continuationFunction, TaskContinuationOptions continuationOptions)
Task< TResult > ContinueWhenAny(Task[] tasks, Func< Task, TResult > continuationFunction)
static void CommonCWAnyLogicCleanup(Task< Task > continuation)
Task ContinueWhenAny(Task[] tasks, Action< Task > continuationAction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
TaskScheduler DefaultScheduler
Task< TResult > StartNew(Func< object?, TResult > function, object? state, CancellationToken cancellationToken)
Task FromAsync(Func< AsyncCallback, object?, IAsyncResult > beginMethod, Action< IAsyncResult > endMethod, object? state)
TaskFactory(TaskCreationOptions creationOptions, TaskContinuationOptions continuationOptions)
TaskFactory(TaskScheduler? scheduler)
Task< TResult > FromAsync(IAsyncResult asyncResult, Func< IAsyncResult, TResult > endMethod, TaskCreationOptions creationOptions, TaskScheduler scheduler)
Task FromAsync(IAsyncResult asyncResult, Action< IAsyncResult > endMethod, TaskCreationOptions creationOptions, TaskScheduler scheduler)
Task< TResult > ContinueWhenAny(Task[] tasks, Func< Task, TResult > continuationFunction, CancellationToken cancellationToken)
static Task< TResult > FromAsyncImpl(Func< AsyncCallback, object, IAsyncResult > beginMethod, Func< IAsyncResult, TResult > endFunction, Action< IAsyncResult > endAction, object state, TaskCreationOptions creationOptions)
readonly TaskCreationOptions m_defaultCreationOptions
static Task< Task > CommonCWAnyLogic(IList< Task > tasks, bool isSyncBlocking=false)
static Task< Task[]> CommonCWAllLogic(Task[] tasksCopy)
Task FromAsync(IAsyncResult asyncResult, Action< IAsyncResult > endMethod)
static Task< TResult > FromAsyncImpl(IAsyncResult asyncResult, Func< IAsyncResult, TResult > endFunction, Action< IAsyncResult > endAction, TaskCreationOptions creationOptions, TaskScheduler scheduler)
Task< TResult > ContinueWhenAll(Task[] tasks, Func< Task[], TResult > continuationFunction)
Task ContinueWhenAny(Task[] tasks, Action< Task > continuationAction)
static Task< TResult > ContinueWhenAllImpl(Task[] tasks, Func< Task[], TResult > continuationFunction, Action< Task[]> continuationAction, TaskContinuationOptions continuationOptions, CancellationToken cancellationToken, TaskScheduler scheduler)
static void CheckFromAsyncOptions(TaskCreationOptions creationOptions, bool hasBeginMethod)
Task< TResult > ContinueWhenAny(Task[] tasks, Func< Task, TResult > continuationFunction, TaskContinuationOptions continuationOptions)
Task< TResult > StartNew(Func< TResult > function, CancellationToken cancellationToken)
static void CheckCreationOptions(TaskCreationOptions creationOptions)
Task< TResult > StartNew(Func< object?, TResult > function, object? state)
Task StartNew(Action action, CancellationToken cancellationToken)
Task< TResult > FromAsync(IAsyncResult asyncResult, Func< IAsyncResult, TResult > endMethod, TaskCreationOptions creationOptions)
Task ContinueWhenAll(Task[] tasks, Action< Task[]> continuationAction)
Task ContinueWhenAll(Task[] tasks, Action< Task[]> continuationAction, TaskContinuationOptions continuationOptions)
Task< TResult > StartNew(Func< object?, TResult > function, object? state, CancellationToken cancellationToken, TaskCreationOptions creationOptions, TaskScheduler scheduler)
Task< TResult > FromAsync(Func< AsyncCallback, object?, IAsyncResult > beginMethod, Func< IAsyncResult, TResult > endMethod, object? state)
readonly TaskScheduler m_defaultScheduler
static Task[] CheckMultiContinuationTasksAndCopy(Task[] tasks)
Task< TResult > FromAsync(IAsyncResult asyncResult, Func< IAsyncResult, TResult > endMethod)
Task< TResult > FromAsync(Func< AsyncCallback, object?, IAsyncResult > beginMethod, Func< IAsyncResult, TResult > endMethod, object? state, TaskCreationOptions creationOptions)
Task< TResult > StartNew(Func< object?, TResult > function, object? state, TaskCreationOptions creationOptions)
static void FromAsyncCoreLogic(IAsyncResult iar, Func< IAsyncResult, TResult > endFunction, Action< IAsyncResult > endAction, Task< TResult > promise, bool requiresSynchronization)
static void CheckMultiTaskContinuationOptions(TaskContinuationOptions continuationOptions)
Task StartNew(Action action, CancellationToken cancellationToken, TaskCreationOptions creationOptions, TaskScheduler scheduler)
Task StartNew(Action action, TaskCreationOptions creationOptions)
Task FromAsync(IAsyncResult asyncResult, Action< IAsyncResult > endMethod, TaskCreationOptions creationOptions)
Task StartNew(Action< object?> action, object? state, CancellationToken cancellationToken, TaskCreationOptions creationOptions, TaskScheduler scheduler)
TaskCreationOptions CreationOptions
Task ContinueWhenAll(Task[] tasks, Action< Task[]> continuationAction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
Task< TResult > StartNew(Func< TResult > function)
Task StartNew(Action< object?> action, object? state, CancellationToken cancellationToken)
Task ContinueWhenAny(Task[] tasks, Action< Task > continuationAction, CancellationToken cancellationToken)
TaskScheduler GetDefaultScheduler(Task currTask)
static Task< TResult > ContinueWhenAnyImpl(Task[] tasks, Func< Task, TResult > continuationFunction, Action< Task > continuationAction, TaskContinuationOptions continuationOptions, CancellationToken cancellationToken, TaskScheduler scheduler)
Task< TResult > ContinueWhenAll(Task[] tasks, Func< Task[], TResult > continuationFunction, CancellationToken cancellationToken)
Task< TResult > StartNew(Func< TResult > function, TaskCreationOptions creationOptions)
TaskFactory(CancellationToken cancellationToken, TaskCreationOptions creationOptions, TaskContinuationOptions continuationOptions, TaskScheduler? scheduler)
Task< TResult > StartNew(Func< TResult > function, CancellationToken cancellationToken, TaskCreationOptions creationOptions, TaskScheduler scheduler)
Task StartNew(Action< object?> action, object? state)
static Task< TResult > CreateCanceledTask(TaskContinuationOptions continuationOptions, CancellationToken ct)
Task< TResult > ContinueWhenAny(Task[] tasks, Func< Task, TResult > continuationFunction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
Task FromAsync(Func< AsyncCallback, object?, IAsyncResult > beginMethod, Action< IAsyncResult > endMethod, object? state, TaskCreationOptions creationOptions)
TaskFactory(CancellationToken cancellationToken)
readonly TaskContinuationOptions m_defaultContinuationOptions
Task StartNew(Action action)
Task StartNew(Action< object?> action, object? state, TaskCreationOptions creationOptions)
TaskContinuationOptions ContinuationOptions
Task< TResult > ContinueWhenAll(Task[] tasks, Func< Task[], TResult > continuationFunction, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler)
Task ContinueWhenAny(Task[] tasks, Action< Task > continuationAction, TaskContinuationOptions continuationOptions)
readonly CancellationToken m_defaultCancellationToken
Task ContinueWhenAll(Task[] tasks, Action< Task[]> continuationAction, CancellationToken cancellationToken)
static TaskScheduler Current
static TaskScheduler Default
static void CreationOptionsFromContinuationOptions(TaskContinuationOptions continuationOptions, out TaskCreationOptions creationOptions, out InternalTaskOptions internalOptions)
static bool s_asyncDebuggingEnabled
void DangerousSetResult(TResult result)
static Task InternalCurrentIfAttached(TaskCreationOptions creationOptions)
bool TrySetCanceled(CancellationToken tokenToRecord)
void InternalRunSynchronously(TaskScheduler scheduler, bool waitForCompletion)
bool TrySetException(object exceptionObject)
static ? Task InternalCurrent
static Task InternalStartNew(Task creatingTask, Delegate action, object state, CancellationToken cancellationToken, TaskScheduler scheduler, TaskCreationOptions options, InternalTaskOptions internalOptions)
static bool AddToActiveTasks(Task task)
static void RemoveFromActiveTasks(Task task)
static bool AnyTaskRequiresNotifyDebuggerOfWaitCompletion(Task[] tasks)
static readonly TplEventSource Log
static RegisteredWaitHandle RegisterWaitForSingleObject(WaitHandle waitObject, WaitOrTimerCallback callBack, object state, uint millisecondsTimeOutInterval, bool executeOnlyOnce, bool flowExecutionContext)
static void ThrowArgumentOutOfRangeException(System.ExceptionArgument argument)
static void ThrowArgumentNullException(string name)
static void ThrowArgumentException(ExceptionResource resource)
static CancellationToken None