How to control a function and threads

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

Dear colleagues

I have a simple function which calls through a function some threads. The
function looks like follow:

Private Sub Refresh( )

Call_ManyOtherThreads_Function(ToDo ) '--> This function creates some
threads
'--> Here I want now to stop the sub until the first call of
Call_ManyOtherThreads_Function( ) is finished.
Call_ManyOtherThreads_Function(ToDo ) '--> This function creates some
threads

End Sub

As you see in the comment, I want to let first finish the first function and
then to call the second function. I tried the following but it doesn't work:

Private Shared mutCon as New Mutex()

Private Sub Refresh( )
mutCon.WaitOne()
Call_ManyOtherThreads_Function( ToDo) ' ---> The last Thread calls the
function mutCon.ReleaseMutex()
'--> Unfortunatelly the Mutex doesn't stop
mutCon.WaitOne()
Call_ManyOtherThreads_Function( ToDo) ' ---> The last Thread calls the
function mutCon.ReleaseMutex()

End Sub

So what am I doing wrong and how can I do this?
Thanks Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top