I am programming to generate keys in hexadecimal using different random function and write it in the text file. I have only two cmd buttons and status bar which displays the current time and the status of the process. Now on clicking the cmd button for keygeneration the form gets locked up and all the other activity is suspended that is even the time is suspended until the process is over. i can even not abort the process in between. I want to solve this problem using the thread if possible. how do i do that please suggest. Else if there is any other method to sort out this issue please suggest.
Thankyou in anticipation of the valuable help
The only "legal" way to do multi-threading in VB6 is through ActiveX EXEs -- just use the thread per object option on the project properties dialog. Matt Curland has a good example how to convert your Standard EXE to a multi-threaded ActiveX EXE. Doing it this way allows VB6 debugger to works w/o crashes because in the IDE everything is executed on a single thread.
If you want to cut down the overhead of ActiveX EXE multi-threading then you have to use in-proc multi-threading which is not supported but still doable. Check Compact In-Process Multi-threading: A FolderWatcher with sample UI for a way to safely use CreateThread and to safely initialize VB6 run-time on the new thread (courtesy Matt Curland again).
You might want to check his Advanced Visual Basic 6 book for more details.
You can use the CreateThread Win32 API but please keep in mind that the VB6 debugger cannot handle multiple threads.
Also, if you have loops of any kind, try slapping "DoEvents" somewhere in the loop. It will severely cut back on performance but your forms will be responsive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With