コード例 #1
0
        /// <summary>
        /// Runs the worker async.
        /// </summary>
        /// <param name="argument">The argument.</param>
        public bool RunWorkerAsync(object argument)
        {
            if (this.IsBusy)
            {
                return(false);
            }
            _count++;

            DoWorkEventArgs args = new DoWorkEventArgs(argument);

            _eventHandler.BeginInvoke(this, args, _workerCallback, args);

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// doworkeventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this DoWorkEventHandler doworkeventhandler, Object sender, DoWorkEventArgs e, AsyncCallback callback)
        {
            if (doworkeventhandler == null)
            {
                throw new ArgumentNullException("doworkeventhandler");
            }

            return(doworkeventhandler.BeginInvoke(sender, e, callback, null));
        }
コード例 #3
0
 void RunWorkerAsync(DoWorkEventHandler doWork, object argument)
 {
     m_CancelPending = false;
     if (doWork != null)
     {
         DoWorkEventArgs args     = new DoWorkEventArgs(argument);
         AsyncCallback   callback = new  AsyncCallback(ReportCompletion);
         doWork.BeginInvoke(this, args, callback, args);
     }
 }