Esempio n. 1
0
            private T3 ScheduleTask <T1, T2, T3>(Func <T1, T2, T3> taskScheduler, string taskName, T1 arg1, T2 arg2) where T3 : Task
            {
                taskName ??= GetType().Name + ".Task";
                var asyncToken = _factory.BeginAsyncOperation(taskName);

                var task = taskScheduler(arg1, arg2);

                _factory.CompleteAsyncOperation(asyncToken, task);
                return(task);
            }
            private TTask ScheduleTaskWorker <TTask>(
                string taskName, Func <TTask> taskCreator, CancellationToken cancellationToken)
                where TTask : Task
            {
                taskName = taskName ?? GetType().Name + ".ScheduleTask";
                var asyncToken = _factory.BeginAsyncOperation(taskName);

                var task = taskCreator();

                _factory.CompleteAsyncOperation(asyncToken, task);
                return(task);
            }