VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > VB.net教程 >
  • VB.NET 异步多线程 DEMO

Function 开启新线程()
Dim back_jd_q As Threading.Thread
back_jd_q = New Threading.Thread(New Threading.ThreadStart(AddressOf 线程委托))
back_jd_q.IsBackground = True
back_jd_q.Start()
End Function
Private Delegate Function back_datarefresh_delegate() '计划数据刷新委托
Private Delegate Function back_uirefresh_delegate(dt As DataTable)

Function 线程委托()

Dim ar As System.IAsyncResult

Dim back_data_delegate As back_datarefresh_delegate

back_data_delegate = AddressOf 信息刷新
ar = back_data_delegate.BeginInvoke(back_CallBackDelegate, back_data_delegate) ‘异步委托执行数据刷新back_CallBackDelegate为处理返回值
End Function

Function 更新UI委托(dt As DataTable)
Dim back_jd_ar1 As System.IAsyncResult
Dim back_ui_delegate As back_uirefresh_delegate
back_ui_delegate = AddressOf 更新UI操作
IMPE_Login.BeginInvoke(New back_uirefresh_delegate(AddressOf 更新UI操作), dt)
End Function

Function 更新UI操作(dt As DataTable)
‘此处加判断是否需要弹窗显示
MsgBox(“信息刷新成功”)

End Function
Private back_CallBackDelegate As AsyncCallback = AddressOf 异步返回处理
Sub 异步返回处理(ByVal ar As IAsyncResult)
Dim dt_return As New DataTable
Dim back_data_delegate As back_datarefresh_delegate
back_data_delegate = ar.AsyncState
dt_return = back_data_delegate.EndInvoke(ar)
更新UI委托(dt_return)
End Sub
Function 信息刷新()

End Function


相关教程