了解BackgroundWorker中的变量范围

时间:2013-07-28 15:00:39

标签: .net vb.net backgroundworker

我有以下方法处理我的BackgroundWorker的DoWork

Public Class BackgroundRunner
   Private Sub BgTask(ByVal sender As Object, ByVal e As DoWorkEventArgs)
       AnotherForm.BgTask(e.Argument)
   End Sub
End Class

Public Class AnotherForm

   Public StartDate As Date

   Public Function BgTask(ByVal e As Object)
       'When I access StartDate here
       'when called via backgroundWorker, I get the default value of 12:00:00 AM
       'When called from another method in the same form, I get its original value
   End Function
End Class

如何通过后台工作程序调用时访问变量?

0 个答案:

没有答案