Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB6 Application Stops Responding

I Have a program written in VB6 that reads a long text file and performs a very long operation. I have also implemented progress bar, but my problem is that, after while my program says "Not responding" and it starts responding again when the task is completed.

How do I remove this 'Not responding' problem?

like image 207
Vinay Kharecha Avatar asked Jun 22 '12 13:06

Vinay Kharecha


2 Answers

Windows/Explorer will change a process to the "Not responding" state when it goes too long without processing any messages. In VB6, this will happen when running a long section of code without calling DoEvents.

Unfortunately, VB6 doesn't easily do multiple threads so you're best option is to periodically call DoEvents during the operation. Ideally, this would be just after updating the progress bar position.

When doing this, you will need to be careful to protect against re-entrancy. This is easy enough by disabling the controls when the long operation starts and re enabling them when it's finished. If you want to let them cancel, you will need to use a boolean value that you set in the cancel button click event and check after calling DoEvents.

like image 53
Deanna Avatar answered Oct 30 '22 00:10

Deanna


You can call DoEvents in your long operation but be careful as it has various caveats associated with it.

like image 21
Alvin Wong Avatar answered Oct 30 '22 00:10

Alvin Wong