Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ FromAsyncImpl() [2/2]

static Task< TResult > System.Threading.Tasks.TaskFactory< TResult >.FromAsyncImpl ( IAsyncResult asyncResult,
Func< IAsyncResult, TResult > endFunction,
Action< IAsyncResult > endAction,
TaskCreationOptions creationOptions,
TaskScheduler scheduler )
inlinestaticpackage

Definition at line 248 of file TaskFactory.cs.

249 {
250 if (asyncResult == null)
251 {
252 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.asyncResult);
253 }
254 if (endFunction == null && endAction == null)
255 {
256 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.endMethod);
257 }
258 if (scheduler == null)
259 {
260 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.scheduler);
261 }
262 TaskFactory.CheckFromAsyncOptions(creationOptions, hasBeginMethod: false);
264 if (TplEventSource.Log.IsEnabled())
265 {
266 TplEventSource.Log.TraceOperationBegin(promise.Id, "TaskFactory.FromAsync", 0L);
267 }
268 if (Task.s_asyncDebuggingEnabled)
269 {
270 Task.AddToActiveTasks(promise);
271 }
273 {
275 }, null, null, default(CancellationToken), TaskCreationOptions.None, InternalTaskOptions.None, null);
276 if (TplEventSource.Log.IsEnabled())
277 {
278 TplEventSource.Log.TraceOperationBegin(t.Id, "TaskFactory.FromAsync Callback", 0L);
279 }
280 if (Task.s_asyncDebuggingEnabled)
281 {
282 Task.AddToActiveTasks(t);
283 }
284 if (asyncResult.IsCompleted)
285 {
286 try
287 {
288 t.InternalRunSynchronously(scheduler, waitForCompletion: false);
289 }
290 catch (Exception exceptionObject)
291 {
292 promise.TrySetException(exceptionObject);
293 }
294 }
295 else
296 {
297 ThreadPool.RegisterWaitForSingleObject(asyncResult.AsyncWaitHandle, delegate
298 {
299 try
300 {
301 t.InternalRunSynchronously(scheduler, waitForCompletion: false);
302 }
303 catch (Exception exceptionObject2)
304 {
305 promise.TrySetException(exceptionObject2);
306 }
307 }, null, -1, executeOnlyOnce: true);
308 }
309 return promise;
310 }
static void FromAsyncCoreLogic(IAsyncResult iar, Func< IAsyncResult, TResult > endFunction, Action< IAsyncResult > endAction, Task< TResult > promise, bool requiresSynchronization)
CancellationToken CancellationToken

References System.Threading.Tasks.Task< TResult >.AddToActiveTasks(), System.asyncResult, System.Threading.Tasks.TaskFactory< TResult >.CheckFromAsyncOptions(), System.creationOptions, System.endFunction, System.Threading.Tasks.TaskFactory< TResult >.FromAsyncCoreLogic(), System.Threading.Tasks.Task< TResult >.Id, System.Threading.Tasks.Task< TResult >.InternalRunSynchronously(), System.L, System.Threading.Tasks.TplEventSource.Log, System.Threading.ThreadPool.RegisterWaitForSingleObject(), System.Threading.Tasks.Task< TResult >.s_asyncDebuggingEnabled, System.scheduler, and System.ThrowHelper.ThrowArgumentNullException().

Referenced by System.Threading.Tasks.TaskFactory< TResult >.FromAsync(), System.Threading.Tasks.TaskFactory< TResult >.FromAsync(), and System.Threading.Tasks.TaskFactory< TResult >.FromAsync().