开发者

Program locking when performing some tasks

I have a program that has the option to create a restore point...

My problem is that when you click on it to do so, the program just locks up until it's finished creating the restore point.

I have put a seperate form on the program and it has a Marquee Progress Bar Control which I downloaded, so the idea is...

User clicks "Create Restore Point"

frmRestore.show Marquee Progress Bar goes on and on while the restore point is created Restore point is done frmRestore.hide

The thing is, when you click create restore point, the form shows and the pr开发者_如何学Googram just locks up, onces the restore point is created the form hides again.

Could this problem be solved with a Background worker? To be honest I'm not completely sure what it does, I mucked around with the controls but can't seem to find anything useful.

Thanks


You need to put the restore procedure in separate thread. If your program is not multi-threaded then it will work linear and lock until it will finish the task it is doing.


The program is locked up because you are doing something intensive on the main thread.

It goes like this in a GUI application:

// do some stuff

// respond to system and redraw gui

// do some stuff

// respond to system and redraw gui

And when you block "// do some stuff" the program won't be able to respond and redraw the gui untill do some stuff is done.

What you need to do is either use a secondary thread or using a background worker like you said. A thread is like, you can do stuff in it without blocking the system or the GUI

hope this helps


I've never seriously used VB, but I think the same concepts apply to Qt (begin rant about Qt being better here).

I'm not sure if VB uses a GUI thread or just one unified one, but I think your problem is that the GUI thread is performing long non-gui operations which cause it to "lock". When it "locks", the program is waiting for the tasks to finish, and hence not letting you interact with it.

Use a separate thread...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜