CreateOperation() public static method

public static CreateOperation ( object userSuppliedState ) : AsyncOperation
userSuppliedState object
return AsyncOperation
Esempio n. 1
0
        public void RunWorkerAsync(object argument)
        {
            if (_isRunning)
            {
                throw new InvalidOperationException(SR.BackgroundWorker_WorkerAlreadyRunning);
            }

            _isRunning           = true;
            _cancellationPending = false;

            _asyncOperation = AsyncOperationManager.CreateOperation(null);
            Task.Factory.StartNew(
                (arg) => WorkerThreadStart(arg),
                argument,
                CancellationToken.None,
                TaskCreationOptions.DenyChildAttach,
                TaskScheduler.Default
                );
        }
Esempio n. 2
0
 /// <summary>
 /// Creates a new async operation.
 /// </summary>
 /// <returns>
 /// An <see cref="AsyncOperation"/>.
 /// </returns>
 protected virtual AsyncOperation CreateAsyncOperation()
 {
     return(AsyncOperationManager.CreateOperation(null));
 }