英語で読む

次の方法で共有


DoWorkEventArgs クラス

定義

DoWork イベント ハンドラーのデータを提供します。

C#
public class DoWorkEventArgs : EventArgs
C#
public class DoWorkEventArgs : System.ComponentModel.CancelEventArgs
継承
DoWorkEventArgs
継承
DoWorkEventArgs

次のコード例では、 クラスを使用してイベントを DoWorkEventArgs 処理する方法を DoWork 示します。 完全なコード一覧については、「 方法: バックグラウンドで操作を実行する」を参照してください。

C#
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;
    }
}

コンストラクター

DoWorkEventArgs(Object)

DoWorkEventArgs クラスの新しいインスタンスを初期化します。

プロパティ

Argument

非同期操作の引数を表す値を取得します。

Cancel

DoWork イベント ハンドラーのデータを提供します。

Cancel

イベントをキャンセルするかどうかを示す値を取得または設定します。

(継承元 CancelEventArgs)
Result

非同期操作の結果を表す値を取得または設定します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象

製品 バージョン
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

こちらもご覧ください