Click to See Complete Forum and Search --> : Threads, how safe are they to use in VB5?


mrhicks
May 16th, 2001, 05:39 PM
Hello,

I have a form that displays a progress bar to show the progress an the current operation. On the form is a timer that is suppose to update the progress bar based upon the start time, current time and the average overall time to complete the process. Within the timer it call certain function that are created using VC++. The problem is that the progress bar isn't updating in real time. It appears that when the a call is made to the VC DLL that it pauses operation of the timer. This makes sense since VB is a single threaded application ( at least from what I understand ). So my options ( from my limited expousre to VB ) are

1) Get the VC++ developers to create a thread and spin off the process. This way it gives back control to the VB code. This is the best solution I feel, but since this portion of the code is froze there is no way I will be able to implement this solution.

2) Is create a seperate thread that only deals with update this progress bar, but from what I have read threads are not that safe in VB.

3) Maybe subclass the WinProc and use this to update the progress bar in some fashion.

I figure my best solution, currently, is to implement a thread, but I need real good reliablity for this apllication. Does anyone have any other suggestions?

Mark

cksiow
May 16th, 2001, 07:41 PM
I feel multithreading is somehow not stable in VB, however, if u would like to implement it, point ur browser to http://vblib.virtualave.net and download the DLL, there is a class vbMultiThreading which might help, come with example as well.

HTH

Clearcode
May 17th, 2001, 03:58 AM
The way that I have handled a similar situation is to have the VB pass a function pointer to an UpdateStatus function that the C dll calls after each iteration. The VB program and C dll are in the same thread and use callbacks so the application is more stable than would be the case with threads.

HTH,
Duncan

-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com

mrhicks
May 18th, 2001, 05:17 AM
This is a nice idea, but unfortunately the C code has been frozen and they is no way I will be able to push this small fix through. They will just have to live with the current implementation I guess until next release.

Mark