BackgroundWorker.RunWorkerAsync 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
백그라운드 작업의 실행을 시작합니다.
오버로드
| Name | Description |
|---|---|
| RunWorkerAsync() |
백그라운드 작업의 실행을 시작합니다. |
| RunWorkerAsync(Object) |
백그라운드 작업의 실행을 시작합니다. |
RunWorkerAsync()
- Source:
- BackgroundWorker.cs
- Source:
- BackgroundWorker.cs
- Source:
- BackgroundWorker.cs
- Source:
- BackgroundWorker.cs
- Source:
- BackgroundWorker.cs
백그라운드 작업의 실행을 시작합니다.
public:
void RunWorkerAsync();
public void RunWorkerAsync();
member this.RunWorkerAsync : unit -> unit
Public Sub RunWorkerAsync ()
예외
IsBusy은 true입니다.
예제
다음 코드 예제에서는 메서드를 사용하여 RunWorkerAsync 비동기 작업을 시작하는 방법을 보여 줍니다. 방법 : 백그라운드에서 파일 다운로드에 설명된 더 큰 예제의 일부입니다.
void downloadButton_Click(object sender, EventArgs e)
{
// Start the download operation in the background.
backgroundWorker1.RunWorkerAsync();
// Disable the button for the duration of the download.
downloadButton.Enabled = false;
// Once you have started the background thread you
// can exit the handler and the application will
// wait until the RunWorkerCompleted event is raised.
// Or if you want to do something else in the main thread,
// such as update a progress bar, you can do so in a loop
// while checking IsBusy to see if the background task is
// still running.
while (backgroundWorker1.IsBusy)
{
progressBar1.Increment(1);
// Keep UI messages moving, so the form remains
// responsive during the asynchronous operation.
Application.DoEvents();
}
}
Private Sub downloadButton_Click( _
ByVal sender As Object, _
ByVal e As EventArgs) _
Handles downloadButton.Click
' Start the download operation in the background.
Me.backgroundWorker1.RunWorkerAsync()
' Disable the button for the duration of the download.
Me.downloadButton.Enabled = False
' Once you have started the background thread you
' can exit the handler and the application will
' wait until the RunWorkerCompleted event is raised.
' If you want to do something else in the main thread,
' such as update a progress bar, you can do so in a loop
' while checking IsBusy to see if the background task is
' still running.
While Me.backgroundWorker1.IsBusy
progressBar1.Increment(1)
' Keep UI messages moving, so the form remains
' responsive during the asynchronous operation.
Application.DoEvents()
End While
End Sub
설명
메서드는 RunWorkerAsync 비동기적으로 실행 중인 작업을 시작하는 요청을 제출합니다. 요청이 처리 DoWork 되면 이벤트가 발생하고 백그라운드 작업의 실행이 시작됩니다.
백그라운드 작업이 이미 실행 중인 경우 다시 호출 RunWorkerAsync 하면 .InvalidOperationException
추가 정보
- DoWork
- 방법: 백그라운드에서 작업 실행
- 관리되는 스레딩 모범 사례
- 방법: 백그라운드에서 파일 다운로드하기
적용 대상
RunWorkerAsync(Object)
- Source:
- BackgroundWorker.cs
- Source:
- BackgroundWorker.cs
- Source:
- BackgroundWorker.cs
- Source:
- BackgroundWorker.cs
- Source:
- BackgroundWorker.cs
백그라운드 작업의 실행을 시작합니다.
public:
void RunWorkerAsync(System::Object ^ argument);
public void RunWorkerAsync(object argument);
public void RunWorkerAsync(object? argument);
member this.RunWorkerAsync : obj -> unit
Public Sub RunWorkerAsync (argument As Object)
매개 변수
예외
IsBusy은 true입니다.
예제
다음 코드 예제에서는 메서드를 사용하여 RunWorkerAsync 비동기 작업을 시작하는 방법을 보여 줍니다. 이 코드 예제는 클래스에 제공된 더 큰 예제의 BackgroundWorker 일부입니다.
// Start the asynchronous operation.
backgroundWorker1->RunWorkerAsync( numberToCompute );
// Start the asynchronous operation.
backgroundWorker1.RunWorkerAsync(numberToCompute);
' Start the asynchronous operation.
backgroundWorker1.RunWorkerAsync(numberToCompute)
설명
메서드는 RunWorkerAsync 비동기적으로 실행 중인 작업을 시작하는 요청을 제출합니다. 요청이 처리 DoWork 되면 이벤트가 발생하고 백그라운드 작업의 실행이 시작됩니다.
작업에 매개 변수가 필요한 경우 매개 변수RunWorkerAsync로 argument 제공할 수 있습니다.
백그라운드 작업이 이미 실행 중인 경우 다시 호출 RunWorkerAsync 하면 .InvalidOperationException
추가 정보
- DoWork
- 방법: 백그라운드에서 작업 실행
- 방법: 백그라운드에서 파일 다운로드하기
- 관리되는 스레딩 모범 사례