DoWorkEventArgs DoWorkEventArgs DoWorkEventArgs DoWorkEventArgs Class

定義

DoWork イベント ハンドラーのデータを提供します。Provides data for the DoWork event handler.

public ref class DoWorkEventArgs : System::ComponentModel::CancelEventArgs
public class DoWorkEventArgs : System.ComponentModel.CancelEventArgs
type DoWorkEventArgs = class
    inherit CancelEventArgs
Public Class DoWorkEventArgs
Inherits CancelEventArgs
継承

DoWorkEventArgsクラスを使用してDoWorkイベントを処理する方法を次のコード例に示します。The following code example demonstrates how to use the DoWorkEventArgs class to handle the DoWork event. 完全なコードリストについては、「方法:バックグラウンドで操作を実行する」を参照してください。For a full code listing, see How to: Run an Operation in the Background.

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(Object) DoWorkEventArgs(Object) DoWorkEventArgs(Object)

DoWorkEventArgs クラスの新しいインスタンスを初期化します。Initializes a new instance of the DoWorkEventArgs class.

プロパティ

Argument Argument Argument Argument

非同期操作の引数を表す値を取得します。Gets a value that represents the argument of an asynchronous operation.

Cancel Cancel Cancel Cancel
Result Result Result Result

非同期操作の結果を表す値を取得または設定します。Gets or sets a value that represents the result of an asynchronous operation.

メソッド

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

指定したオブジェクトが、現在のオブジェクトと等しいかどうかを判断します。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

既定のハッシュ関数として機能します。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

現在のインスタンスの Type を取得します。Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

現在の Object の簡易コピーを作成します。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

現在のオブジェクトを表す文字列を返します。Returns a string that represents the current object.

(Inherited from Object)

適用対象

こちらもご覧ください