Beispiel #1
0
        // TAP
        internal PageAsyncTask(Func <CancellationToken, Task> handler, SynchronizationContextMode currentMode)
        {
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }

            // The legacy PageAsyncTaskManager doesn't support TAP methods
            SynchronizationContextUtil.ValidateMode(currentMode, requiredMode: SynchronizationContextMode.Normal, specificErrorMessage: SR.SynchronizationContextUtil_TaskReturningPageAsyncMethodsNotCompatible);

            TaskHandler = handler;
        }
Beispiel #2
0
        // APM
        internal PageAsyncTask(BeginEventHandler beginHandler, EndEventHandler endHandler, EndEventHandler timeoutHandler, Object state, bool executeInParallel, SynchronizationContextMode currentMode)
        {
            if (beginHandler == null)
            {
                throw new ArgumentNullException("beginHandler");
            }
            if (endHandler == null)
            {
                throw new ArgumentNullException("endHandler");
            }

            // Only the legacy PageAsyncTaskManager supports timing out APM methods or executing them in parallel
            if (timeoutHandler != null || executeInParallel)
            {
                SynchronizationContextUtil.ValidateMode(currentMode, requiredMode: SynchronizationContextMode.Legacy, specificErrorMessage: SR.SynchronizationContextUtil_PageAsyncTaskTimeoutHandlerParallelNotCompatible);
            }

            BeginHandler      = beginHandler;
            EndHandler        = endHandler;
            TimeoutHandler    = timeoutHandler;
            State             = state;
            ExecuteInParallel = executeInParallel;
        }