DoWorkEventArgs 类   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
为 DoWork 事件处理程序提供数据。
public ref class DoWorkEventArgs : EventArgs
	public ref class DoWorkEventArgs : System::ComponentModel::CancelEventArgs
	public class DoWorkEventArgs : EventArgs
	public class DoWorkEventArgs : System.ComponentModel.CancelEventArgs
	type DoWorkEventArgs = class
    inherit EventArgs
	type DoWorkEventArgs = class
    inherit CancelEventArgs
	Public Class DoWorkEventArgs
Inherits EventArgs
	Public Class DoWorkEventArgs
Inherits CancelEventArgs
		- 继承
 
- 继承
 
示例
下面的代码示例演示如何使用 DoWorkEventArgs 类来处理 DoWork 事件。 有关完整代码列表,请参阅 如何:在后台运行操作。
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
    // Do not access the form's BackgroundWorker reference directly.
    // Instead, use the reference provided by the sender parameter.
    BackgroundWorker bw = sender as BackgroundWorker;
    // Extract the argument.
    int arg = (int)e.Argument;
    // Start the time-consuming operation.
    e.Result = TimeConsumingOperation(bw, arg);
    // If the operation was canceled by the user, 
    // set the DoWorkEventArgs.Cancel property to true.
    if (bw.CancellationPending)
    {
        e.Cancel = true;
    }
}
Private Sub backgroundWorker1_DoWork( _
sender As Object, e As DoWorkEventArgs) _
Handles backgroundWorker1.DoWork
   ' Do not access the form's BackgroundWorker reference directly.
   ' Instead, use the reference provided by the sender parameter.
   Dim bw As BackgroundWorker = CType( sender, BackgroundWorker )
   
   ' Extract the argument.
   Dim arg As Integer = Fix(e.Argument)
   
   ' Start the time-consuming operation.
   e.Result = TimeConsumingOperation(bw, arg)
   
   ' If the operation was canceled by the user, 
   ' set the DoWorkEventArgs.Cancel property to true.
   If bw.CancellationPending Then
      e.Cancel = True
   End If
End Sub
	构造函数
| DoWorkEventArgs(Object) | 
		 初始化 DoWorkEventArgs 类的新实例。  | 
        	
属性
| Argument | 
		 获取表示异步操作参数的值。  | 
        	
| Cancel | 
		 为 DoWork 事件处理程序提供数据。  | 
        	
| Cancel | 
		 获取或设置指示是否应取消事件的值。 (继承自 CancelEventArgs) | 
        	
| Result | 
		 获取或设置表示异步操作结果的值。  | 
        	
方法
| Equals(Object) | 
		 确定指定对象是否等于当前对象。 (继承自 Object) | 
        	
| GetHashCode() | 
		 作为默认哈希函数。 (继承自 Object) | 
        	
| GetType() | 
		 获取当前实例的 Type。 (继承自 Object) | 
        	
| MemberwiseClone() | 
		 创建当前 Object 的浅表副本。 (继承自 Object) | 
        	
| ToString() | 
		 返回表示当前对象的字符串。 (继承自 Object) |