开发者

Techniques for not allowing a vb.net program to enter "Not responding mode"

I h开发者_开发知识库ave a program that runs a pretty long operation in the background once a user clicks the button. I have implemented a progress bar but if the window is touched or moved then it grays out and says (Not repsonding). Everything still works and when the operation finishes the program resumes function. (But a user would not know this :(

Any ideas on the best way to keep this from happeneing I working with vb.net in Visual Studio 2010


I would guess that some use of threading would help that. You would send the actual operation into a new thread, different than the thread responsible for the running application.


Moving your processing out of the main UI thread into a background worker thread is the best solution, but a short term fix just to get the window responding might be to use Application.DoEvents in an appropriate place in your processing code.

But be warned that it can create some re-entrancy problems if the user can still perform actions on your form.


Use a BackgroundWorker or the Thread Pool to run tasks on a different thread whilst keeping your UI (user interface) responsive.

Also, check out this excellent free eBook (in C# I'm afraid) for everything you'll need to know about threading:

http://www.albahari.com/threading/#_Introduction

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜