System.ComponentModel.BackgroundWorker.OnDoWork C# (CSharp) Method

OnDoWork() protected method

protected OnDoWork ( DoWorkEventArgs e ) : void
e DoWorkEventArgs
return void
        protected virtual void OnDoWork(DoWorkEventArgs e)
        {
            DoWorkEventHandler handler = (DoWorkEventHandler)(Events[doWorkKey]);
            if (handler != null)
            {
                handler(this, e);
            }
        }

Usage Example

Beispiel #1
0
            /// <summary>
            /// Perform the background work.
            /// </summary>
            private void DoWork()
            {
                // Perform work
                try
                {
                    var args = new DoWorkEventArgs(argument);
                    worker.OnDoWork(args);
                    result = args.Result;
                }
                catch (Exception ex)
                {
                    error = ex;
                }

                // Invoke result handler
                resultHandler.SendEmptyMessage(0);
            }