internal static Task <TResult> ContinueWhenAny <TAntecedentResult>(Task <TAntecedentResult>[] tasks, Func <Task <TAntecedentResult>, TResult> continuationFunction, TaskContinuationOptions continuationOptions, System.Threading.CancellationToken cancellationToken, TaskScheduler scheduler, ref StackCrawlMark stackMark)
 {
     TaskFactory.CheckMultiTaskContinuationOptions(continuationOptions);
     if (tasks == null)
     {
         throw new ArgumentNullException("tasks");
     }
     if (continuationFunction == null)
     {
         throw new ArgumentNullException("continuationFunction");
     }
     if (scheduler == null)
     {
         throw new ArgumentNullException("scheduler");
     }
     Task <TAntecedentResult>[] taskArray = TaskFactory.CheckMultiContinuationTasksAndCopy <TAntecedentResult>(tasks);
     if (cancellationToken.IsCancellationRequested)
     {
         return(TaskFactory <TResult> .CreateCanceledTask(continuationOptions));
     }
     return(TaskFactory.CommonCWAnyLogic((Task[])taskArray).ContinueWith <TResult>(completedTask => this.continuationFunction(completedTask.Result as Task <TAntecedentResult>), scheduler, cancellationToken, continuationOptions, ref stackMark));
 }