最終更新:2017-12-07 (木) 16:02:20 (11d)  

System.ComponentModel.BackgroundWorker はてなブックマークを見る
Top / System.ComponentModel.BackgroundWorker

https://msdn.microsoft.com/ja-jp/library/system.componentmodel.backgroundworker(v=vs.110).aspx

  • .NET Framework 2.0から導入
  • デリゲートInvokeAddressOf?とかを使わないでマルチスレッドの処理ができる
  • System.ComponentModel.BackgroundWorker
    Public Class Form1
      //スレッドの処理
      Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        System.Threading.Thread.Sleep(New TimeSpan(0, 0, 3))
      End Sub
    
      //完了時の処理
      Private Sub BackgroundWorker1_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BackgroundWorker1.RunWorkerCompleted
        Me.Label1.Text = "Done!"
      End Sub
    
      //呼び出し
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.BackgroundWorker1.RunWorkerAsync()
      End Sub
    End Class

イベント

  • BackgroundWorker.DoWork?
    BackgroundWorker.ProgressChanged?
    BackgroundWorker.RunWorkerCompleted?

関連