/// <summary>
        /// Setups up a background action with a simple action.
        /// </summary>
        /// <param name="action">The background action to be performed when start is called.  The action must return when the cancellation token is canceled.</param>
        public BackgroundOperation(BackgroundOperationAction action) : this()
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            _backgroundOperation = (arg1, arg2, cancelToken) => {
                action?.Invoke(arg1, arg2, cancelToken);
                return(Task.CompletedTask);
            };
        }
예제 #2
0
 /// <summary>
 /// Setups up a background action with a simple action.
 /// </summary>
 /// <param name="action">The background action to be performed when start is called.  The action must return when the cancellation token is canceled.</param>
 public BackgroundOperationDisposable(BackgroundOperationAction action) : base(action)
 {
 }