【发布时间】:2012-03-04 08:48:50
【问题描述】:
我在线程函数中调用一个类函数。我正在使用调用方法将值发送到主窗体中的进度条,但我不知道如何在线程函数调用的其他类函数中执行此操作。
我的目标是从线程函数甚至从线程函数调用的函数向主窗体发送一个值到进度条。
我的代码: '调用子 Public Sub UpdPgEvent(ByVal value As Integer) Me.pgFindEvent.Value = 值 结束子
' Sub started by the thread
Private Sub ThreadTaskMonitor()
Dim ConnectURL As String
' Delegate progressbar
Dim DelegPgEvent As DelegueUpgPbEvent = New DelegueUpgPbEvent(AddressOf UpdPgEvent)
' This invoke works great
Me.Invoke(DelegPgEvent, 10)
ConnectURL = "..."
Me.Invoke(DelegPgEvent, 20)
' What I want is to send state value from this call to the main form progressbar
urlr.JsonGetEvents(ConnectURL)
Dim table_res As List(Of monitor_table) = urlr.ConstructDataMonitor()
Me.Invoke(DelegPgEvent, 80)
Me.MonitorBindingSource.DataSource = table_res
Me.Invoke(DelegPgEvent, 90)
mon.dbMonitor.DataSource = Me.MonitorBindingSource
Me.Invoke(DelegPgEvent, 0)
End Sub
感谢您的帮助
【问题讨论】:
-
你能修改urlr类吗?如果是这样,则在那里引发事件并在您的调用类中处理它。
标签: vb.net multithreading invoke