diff options
Diffstat (limited to 'src/mscorlib/src/System/Threading/Tasks/FutureFactory.cs')
-rw-r--r-- | src/mscorlib/src/System/Threading/Tasks/FutureFactory.cs | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/mscorlib/src/System/Threading/Tasks/FutureFactory.cs b/src/mscorlib/src/System/Threading/Tasks/FutureFactory.cs index 137afa11f5..60a7c81dcf 100644 --- a/src/mscorlib/src/System/Threading/Tasks/FutureFactory.cs +++ b/src/mscorlib/src/System/Threading/Tasks/FutureFactory.cs @@ -568,8 +568,6 @@ namespace System.Threading.Tasks promise.DangerousSetResult(result); } } - - } } @@ -691,7 +689,7 @@ namespace System.Threading.Tasks // RespectParentCancellation. Task t = new Task(new Action<object>(delegate { - FromAsyncCoreLogic(asyncResult, endFunction, endAction, promise, requiresSynchronization:true); + FromAsyncCoreLogic(asyncResult, endFunction, endAction, promise, requiresSynchronization: true); }), (object)null, null, default(CancellationToken), TaskCreationOptions.None, InternalTaskOptions.None, null); @@ -706,7 +704,7 @@ namespace System.Threading.Tasks if (asyncResult.IsCompleted) { - try { t.InternalRunSynchronously(scheduler, waitForCompletion:false); } + try { t.InternalRunSynchronously(scheduler, waitForCompletion: false); } catch (Exception e) { promise.TrySetException(e); } // catch and log any scheduler exceptions } else @@ -792,7 +790,7 @@ namespace System.Threading.Tasks ThrowHelper.ThrowArgumentNullException(ExceptionArgument.endMethod); Contract.Requires((endFunction != null) != (endAction != null), "Both endFunction and endAction were non-null"); - + TaskFactory.CheckFromAsyncOptions(creationOptions, true); Task<TResult> promise = new Task<TResult>(state, creationOptions); @@ -943,7 +941,6 @@ namespace System.Threading.Tasks } catch { - if (AsyncCausalityTracer.LoggingOn) AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, promise.Id, AsyncCausalityStatus.Error); @@ -1241,7 +1238,7 @@ namespace System.Threading.Tasks internal static Task<TResult> FromAsyncTrim<TInstance, TArgs>( TInstance thisRef, TArgs args, Func<TInstance, TArgs, AsyncCallback, object, IAsyncResult> beginMethod, - Func<TInstance, IAsyncResult, TResult> endMethod) + Func<TInstance, IAsyncResult, TResult> endMethod) where TInstance : class { // Validate arguments, but only with asserts, as this is an internal only implementation. @@ -1319,7 +1316,7 @@ namespace System.Threading.Tasks // we'll instead complete the promise at the call site. if (!asyncResult.CompletedSynchronously) { - promise.Complete(thisRef, endMethod, asyncResult, requiresSynchronization:true); + promise.Complete(thisRef, endMethod, asyncResult, requiresSynchronization: true); } } @@ -1661,7 +1658,7 @@ namespace System.Threading.Tasks return ContinueWhenAllImpl<TAntecedentResult>(tasks, continuationFunction, null, continuationOptions, cancellationToken, scheduler); } - + // Core implementation of ContinueWhenAll -- the generic version // Note: if you make any changes to this method, please do the same to the non-generic version too. internal static Task<TResult> ContinueWhenAllImpl<TAntecedentResult>(Task<TAntecedentResult>[] tasks, @@ -1744,10 +1741,10 @@ namespace System.Threading.Tasks //the following delegate avoids closure capture as much as possible //completedTasks.Result == tasksCopy; //state == continuationFunction - (completedTasks, state) => + (completedTasks, state) => { completedTasks.NotifyDebuggerOfWaitCompletionIfNecessary(); - return ((Func<Task[], TResult>)state)(completedTasks.Result); + return ((Func<Task[], TResult>)state)(completedTasks.Result); }, continuationFunction, scheduler, cancellationToken, continuationOptions); } @@ -1755,13 +1752,13 @@ namespace System.Threading.Tasks { Debug.Assert(continuationAction != null); return starter.ContinueWith<TResult>( - //the following delegate avoids closure capture as much as possible - //completedTasks.Result == tasksCopy; - //state == continuationAction - (completedTasks, state) => + //the following delegate avoids closure capture as much as possible + //completedTasks.Result == tasksCopy; + //state == continuationAction + (completedTasks, state) => { completedTasks.NotifyDebuggerOfWaitCompletionIfNecessary(); - ((Action<Task[]>)state)(completedTasks.Result); return default(TResult); + ((Action<Task[]>)state)(completedTasks.Result); return default(TResult); }, continuationAction, scheduler, cancellationToken, continuationOptions); } @@ -2054,7 +2051,7 @@ namespace System.Threading.Tasks // check arguments TaskFactory.CheckMultiTaskContinuationOptions(continuationOptions); if (tasks == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.tasks); - if(tasks.Length == 0) ThrowHelper.ThrowArgumentException( ExceptionResource.Task_MultiTaskContinuation_EmptyTaskList, ExceptionArgument.tasks); + if (tasks.Length == 0) ThrowHelper.ThrowArgumentException(ExceptionResource.Task_MultiTaskContinuation_EmptyTaskList, ExceptionArgument.tasks); //ArgumentNullException of continuationFunction or continuationAction is checked by the caller Contract.Requires((continuationFunction != null) != (continuationAction != null), "Expected exactly one of endFunction/endAction to be non-null"); @@ -2076,8 +2073,8 @@ namespace System.Threading.Tasks if (continuationFunction != null) { return starter.ContinueWith( - //the following delegate avoids closure capture as much as possible - //completedTask.Result is the winning task; state == continuationAction + //the following delegate avoids closure capture as much as possible + //completedTask.Result is the winning task; state == continuationAction (completedTask, state) => { return ((Func<Task, TResult>)state)(completedTask.Result); }, continuationFunction, scheduler, cancellationToken, continuationOptions); } @@ -2132,7 +2129,7 @@ namespace System.Threading.Tasks Debug.Assert(continuationAction != null); return starter.ContinueWith<TResult>( // Use a cached delegate - GenericDelegateCache<TAntecedentResult,TResult>.CWAnyActionDelegate, + GenericDelegateCache<TAntecedentResult, TResult>.CWAnyActionDelegate, continuationAction, scheduler, cancellationToken, continuationOptions); } } @@ -2180,7 +2177,5 @@ namespace System.Threading.Tasks action(wrappedAntecedents.Result); return default(TResult); }; - } - } |