using System; using System.Threading; namespace System.ComponentModel { /// Executes an operation on a separate thread. // Token: 0x02000058 RID: 88 public class BackgroundWorker { /// Occurs when is called. // Token: 0x14000010 RID: 16 // (add) Token: 0x06000366 RID: 870 RVA: 0x0000A7C0 File Offset: 0x000089C0 // (remove) Token: 0x06000367 RID: 871 RVA: 0x0000A7DC File Offset: 0x000089DC public event DoWorkEventHandler DoWork; /// Occurs when is called. // Token: 0x14000011 RID: 17 // (add) Token: 0x06000368 RID: 872 RVA: 0x0000A7F8 File Offset: 0x000089F8 // (remove) Token: 0x06000369 RID: 873 RVA: 0x0000A814 File Offset: 0x00008A14 public event ProgressChangedEventHandler ProgressChanged; /// Occurs when the background operation has completed, has been canceled, or has raised an exception. // Token: 0x14000012 RID: 18 // (add) Token: 0x0600036A RID: 874 RVA: 0x0000A830 File Offset: 0x00008A30 // (remove) Token: 0x0600036B RID: 875 RVA: 0x0000A84C File Offset: 0x00008A4C public event RunWorkerCompletedEventHandler RunWorkerCompleted; /// Gets a value indicating whether the application has requested cancellation of a background operation. /// true if the application has requested cancellation of a background operation; otherwise, false. The default is false. // Token: 0x170000EF RID: 239 // (get) Token: 0x0600036C RID: 876 RVA: 0x0000A868 File Offset: 0x00008A68 public bool CancellationPending { get { return this.cancel_pending; } } /// Gets a value indicating whether the is running an asynchronous operation. /// true, if the is running an asynchronous operation; otherwise, false. // Token: 0x170000F0 RID: 240 // (get) Token: 0x0600036D RID: 877 RVA: 0x0000A870 File Offset: 0x00008A70 public bool IsBusy { get { return this.async != null; } } /// Gets or sets a value indicating whether the can report progress updates. /// true if the supports progress updates; otherwise false. The default is false. // Token: 0x170000F1 RID: 241 // (get) Token: 0x0600036E RID: 878 RVA: 0x0000A880 File Offset: 0x00008A80 // (set) Token: 0x0600036F RID: 879 RVA: 0x0000A888 File Offset: 0x00008A88 [DefaultValue(false)] public bool WorkerReportsProgress { get { return this.report_progress; } set { this.report_progress = value; } } /// Gets or sets a value indicating whether the supports asynchronous cancellation. /// true if the supports cancellation; otherwise false. The default is false. // Token: 0x170000F2 RID: 242 // (get) Token: 0x06000370 RID: 880 RVA: 0x0000A894 File Offset: 0x00008A94 // (set) Token: 0x06000371 RID: 881 RVA: 0x0000A89C File Offset: 0x00008A9C [DefaultValue(false)] public bool WorkerSupportsCancellation { get { return this.support_cancel; } set { this.support_cancel = value; } } /// Requests cancellation of a pending background operation. /// /// is false. /// /// /// // Token: 0x06000372 RID: 882 RVA: 0x0000A8A8 File Offset: 0x00008AA8 public void CancelAsync() { if (!this.support_cancel) { throw new InvalidOperationException("This background worker does not support cancellation."); } if (!this.IsBusy) { return; } this.cancel_pending = true; } /// Raises the event. /// The percentage, from 0 to 100, of the background operation that is complete. /// The property is set to false. // Token: 0x06000373 RID: 883 RVA: 0x0000A8D4 File Offset: 0x00008AD4 public void ReportProgress(int percentProgress) { this.ReportProgress(percentProgress, null); } /// Raises the event. /// The percentage, from 0 to 100, of the background operation that is complete. /// The state object passed to . /// The property is set to false. // Token: 0x06000374 RID: 884 RVA: 0x0000A8E0 File Offset: 0x00008AE0 public void ReportProgress(int percentProgress, object userState) { if (!this.WorkerReportsProgress) { throw new InvalidOperationException("This background worker does not report progress."); } if (!this.IsBusy) { return; } this.async.Post(delegate(object o) { ProgressChangedEventArgs progressChangedEventArgs = o as ProgressChangedEventArgs; this.OnProgressChanged(progressChangedEventArgs); }, new ProgressChangedEventArgs(percentProgress, userState)); } /// Starts execution of a background operation. /// /// is true. /// /// /// // Token: 0x06000375 RID: 885 RVA: 0x0000A930 File Offset: 0x00008B30 public void RunWorkerAsync() { this.RunWorkerAsync(null); } // Token: 0x06000376 RID: 886 RVA: 0x0000A93C File Offset: 0x00008B3C private void ProcessWorker(object argument, AsyncOperation async, SendOrPostCallback callback) { Exception ex = null; DoWorkEventArgs doWorkEventArgs = new DoWorkEventArgs(argument); try { this.OnDoWork(doWorkEventArgs); } catch (Exception ex2) { ex = ex2; doWorkEventArgs.Cancel = false; } callback(new object[] { new RunWorkerCompletedEventArgs(doWorkEventArgs.Result, ex, doWorkEventArgs.Cancel), async }); } // Token: 0x06000377 RID: 887 RVA: 0x0000A9B0 File Offset: 0x00008BB0 private void CompleteWorker(object state) { object[] array = (object[])state; RunWorkerCompletedEventArgs runWorkerCompletedEventArgs = array[0] as RunWorkerCompletedEventArgs; AsyncOperation asyncOperation = array[1] as AsyncOperation; SendOrPostCallback sendOrPostCallback = delegate(object darg) { this.async = null; this.OnRunWorkerCompleted(darg as RunWorkerCompletedEventArgs); }; asyncOperation.PostOperationCompleted(sendOrPostCallback, runWorkerCompletedEventArgs); this.cancel_pending = false; } /// Starts execution of a background operation. /// A parameter for use by the background operation to be executed in the event handler. /// /// is true. // Token: 0x06000378 RID: 888 RVA: 0x0000A9F4 File Offset: 0x00008BF4 public void RunWorkerAsync(object argument) { if (this.IsBusy) { throw new InvalidOperationException("The background worker is busy."); } this.async = AsyncOperationManager.CreateOperation(this); BackgroundWorker.ProcessWorkerEventHandler processWorkerEventHandler = new BackgroundWorker.ProcessWorkerEventHandler(this.ProcessWorker); processWorkerEventHandler.BeginInvoke(argument, this.async, new SendOrPostCallback(this.CompleteWorker), null, null); } /// Raises the event. /// An that contains the event data. // Token: 0x06000379 RID: 889 RVA: 0x0000AA4C File Offset: 0x00008C4C protected virtual void OnDoWork(DoWorkEventArgs e) { if (this.DoWork != null) { this.DoWork(this, e); } } /// Raises the event. /// An that contains the event data. // Token: 0x0600037A RID: 890 RVA: 0x0000AA68 File Offset: 0x00008C68 protected virtual void OnProgressChanged(ProgressChangedEventArgs e) { if (this.ProgressChanged != null) { this.ProgressChanged(this, e); } } /// Raises the event. /// An that contains the event data. // Token: 0x0600037B RID: 891 RVA: 0x0000AA84 File Offset: 0x00008C84 protected virtual void OnRunWorkerCompleted(RunWorkerCompletedEventArgs e) { if (this.RunWorkerCompleted != null) { this.RunWorkerCompleted(this, e); } } // Token: 0x0400011A RID: 282 private AsyncOperation async; // Token: 0x0400011B RID: 283 private bool cancel_pending; // Token: 0x0400011C RID: 284 private bool report_progress; // Token: 0x0400011D RID: 285 private bool support_cancel; // Token: 0x02000307 RID: 775 // (Invoke) Token: 0x06001BF5 RID: 7157 private delegate void ProcessWorkerEventHandler(object argument, AsyncOperation async, SendOrPostCallback callback); } }