Waiting in vb.net

  • Thread starter Thread starter Peter van der Veen
  • Start date Start date
P

Peter van der Veen

Hi

What is the best to use.

I've a form with an animated gif and a function to carry out.

If i show the form and call the function the gif freezes.

So i start a new thread which carries out the function and the gif is
animating.
I use a loop to check if the function is ready (i set a var to true if
the function terminates) and in the loop i call the DoEvents function.


Do while bRunning
Systems.Windows.Form.Application.Doevents()
Loop

Is there maybe a better method? Could i use a sleep function? Or will
the complete program goes to sleep,

Peter
 
* Peter van der Veen said:
So i start a new thread which carries out the function and the gif is
animating.
I use a loop to check if the function is ready (i set a var to true if
the function terminates) and in the loop i call the DoEvents function.

You can call a method of the form from within your other thread. Have a
look at the form's 'Invoke' method (you cannot access instance members
of a form from another thread directly).
 
Hi Peter,

For this use the sleep methode in your do events loop.

do while myGifIsNotReady
application.doevents
threading.thread.sleep(50)
next

Or something.

I hope this helps

Cor
 
Back
Top