当前位置:   article > 正文

VB.NET 异步多线程 DEMO

vb 多线程 异步

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

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号