本文介绍了如何使用backgroundworker来打开MdiChildren表单. -在vb.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用backgroundworker
在主窗体(mdi父窗体)上打开仪表板的子窗体或进入vb.net.


how can i open child forms for dash board on main form(mdi parent form) using backgroundworker
or thread into vb.net.


Private Sub Main_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
     bWorker.RunWorkerAsync()
End Sub

Private Sub bWorker_DoWork(ByVal sender As Object, ByVal e As _
  System.ComponentModel.DoWorkEventArgs) Handles bWorker.DoWork
      ViewDashBoard() 'this is my method to show child forms on dash board
End Sub




我用仪表板显示了用户的详细信息,如清单,联系人等,因此
需要更多时间,所以我的主要表单加载时间增加了,这就是为什么我要使用backgroundworker.

请帮帮我. :-)




i used dash board to show user detail like to do list,contacts etc. on main from so its
take more time so my main form loading time is increase thats why i want to use backgroundworker.

help me please. :-)

推荐答案


e.Result=list


您无法在此函数中更新ListBox,否则将收到错误消息.

下一步是通过执行以下操作来使用RunWorkerCompleted事件:


You cannot update the ListBox in this function, you will receive an error if you do so.

Next step is to use the RunWorkerCompleted event by doing this :

AddHandler(backgroundWorker.RunWorkerCompleted,AddressOf(back_RunWorkerCompleted))



因此,在函数back_RunWorkerCompleted中,您可以使用e.Result获得Do_Work的结果. (e在RunWorkerCompleted的参数中).
然后,您可以使用该结果更新UI控件.因此,现在您的ListBox可以在此处使用e.Result进行更新.

您可以在此处查看我的博客: http://tarundotnet.wordpress.com/2011/03/14/using-backgroundworker-in-wpf-applications/ [ ^ ],它在WPF中,但是我已经在此处进行了解释.

希望能有所帮助! :)



So in the function back_RunWorkerCompleted, you can get the result of the Do_Work using e.Result. (e is in the Argument of RunWorkerCompleted).
Then you can update your UI Controls using that Result. So now your ListBox can be updated here with the e.Result.

You can check my blog here : http://tarundotnet.wordpress.com/2011/03/14/using-backgroundworker-in-wpf-applications/[^], its in WPF, but i have explained there.

Hope it helped! :)


这篇关于如何使用backgroundworker来打开MdiChildren表单. -在vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 02:09