DoWorkEventHandler DoWorkEventHandler DoWorkEventHandler DoWorkEventHandler Delegate

정의

DoWork 이벤트를 처리할 메서드를 나타냅니다.Represents the method that will handle the DoWork event. 이 클래스는 상속될 수 없습니다.This class cannot be inherited.

public delegate void DoWorkEventHandler(System::Object ^ sender, DoWorkEventArgs ^ e);
public delegate void DoWorkEventHandler(object sender, DoWorkEventArgs e);
type DoWorkEventHandler = delegate of obj * DoWorkEventArgs -> unit
Public Delegate Sub DoWorkEventHandler(sender As Object, e As DoWorkEventArgs)

매개 변수

sender
Object Object Object Object

이벤트 소스입니다.The source of the event.

e
DoWorkEventArgs DoWorkEventArgs DoWorkEventArgs DoWorkEventArgs

이벤트 데이터를 포함하는 DoWorkEventArgs입니다.A DoWorkEventArgs that contains the event data.

상속
DoWorkEventHandlerDoWorkEventHandlerDoWorkEventHandlerDoWorkEventHandler

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 DoWorkEventHandler 처리 하는 대리자는 DoWork 이벤트입니다.The following code example demonstrates how to use the DoWorkEventHandler delegate 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   

설명

DoWorkEventHandler 대리자를 만들 때, 이벤트를 처리할 메서드를 식별합니다.When you create a DoWorkEventHandler delegate, you identify the method that will handle the event. 이벤트를 이벤트 처리기와 연결하려면 대리자의 인스턴스를 해당 이벤트에 추가합니다.To associate the event with your event handler, add an instance of the delegate to the event. 대리자를 제거 하지 않는 한 이벤트 처리기 메서드는 이벤트가 발생할 때마다 호출 됩니다.The event-handler method is called whenever the event occurs, unless you remove the delegate. 이벤트 처리기 대리자에 대 한 자세한 내용은 참조 하세요. 이벤트 처리 및 발생합니다.For more information about event-handler delegates, see Handling and Raising Events.

Extension Methods

GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate) GetMethodInfo(Delegate)

지정 된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다.Gets an object that represents the method represented by the specified delegate.

적용 대상

추가 정보