本文介绍了使用BackgroundWorker类时UI挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要在单击网页的按钮上运行后台进程,并且该页面不应该挂起/等待完成该进程,以便用户可以在Web应用程序上做任何想做的事情.

我的解决方案:

1)我使用BackgroundWorker类,即使我关闭了UI作业也完成了,但是如果我不关闭UI,它会挂起,直到处理完成.

2)我在WS中使用了webservice和backgroundworker clas.但是它显示出与第一个结果相同的结果.. :(


请帮助我..在后台工作时我需要UI是免费的..

提前谢谢.



干杯,
Divya

[edit]从主题中删除了紧急" [edit]

Hi,

I need to run a background process on a button click on a web page and the page shoud not hang/wait to complete the process so that user can do whatever he wants to do on the webapp.

My solutions:

1) I used BackgroundWorker class and even if I close the UI job gets done but if I dont close UI, It gets hang untill process gets complete.

2) I used webservice and used backgroundworker clas in WS. But it shows same result as the 1st one .. :(


Please help me .. I need UI to be free .. while workingon background job..

Thanks in advance.



Cheers,
Divya

[edit]Removed "urgent" from subject[edit]

推荐答案


Private Sub DoSomethingInBackGround()
        'System.Threading.Thread.Sleep(10000)
End Sub

Protected Sub btnRunInBackGround_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRunInBackGround.Click
        Dim backGroundThreadStart As New Threading.ThreadStart(AddressOf DoSomethingInBackGround)
        Dim backGroundThread As New Threading.Thread(backGroundThreadStart)
        backGroundThread.Start()
End Sub


这篇关于使用BackgroundWorker类时UI挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 07:46
查看更多