M
Manuel
I have a long function that needs to be done 1000 times. I'm
multithreading it, but I don't want to load them up all at once, instead
load them 10 at a time.
So far the only way I can get it to work is by creating a dummy form
with a timer. On the timer function I test if the number of threads are
less than 10 then run the remaining ones. This is working fine, but I
would like to know how to do it without the form.
This is the code I'm trying to use to accomplish the feat without the form:
Module mdlAny()
Public Sub Main()
Do
FunctionThatCalls10Threads()
PauseThisThing() 'Replace this with
'either of the bottom functions
Loop
End Sub
Private Sub PauseThisThingThatWorks()
'It works with this code:
'On the Timer event, I call
'the FunctionThatChecksTheNumberOfThreads()
'to see if I can close the form.
'(and hence continue with the program)
Dim wf As WaitForm = New WaitForm
wf.ShowDialog()
End Sub
Private Sub PauseThisThingThatDOESNOTWork()
'It doesn't work with this code for waiting
Dim RetValue as Boolean
Do
System.Threading.Thread.CurrentThread.Sleep(1000)
RetValue = FunctionThatChecksTheNumberOfThreads()
Loop Until RetValue
End Sub
End Module
.................................................................
Posted via TITANnews - Uncensored Newsgroups Access-=Every Newsgroup - Anonymous, UNCENSORED, BROADBAND Downloads=-
multithreading it, but I don't want to load them up all at once, instead
load them 10 at a time.
So far the only way I can get it to work is by creating a dummy form
with a timer. On the timer function I test if the number of threads are
less than 10 then run the remaining ones. This is working fine, but I
would like to know how to do it without the form.
This is the code I'm trying to use to accomplish the feat without the form:
Module mdlAny()
Public Sub Main()
Do
FunctionThatCalls10Threads()
PauseThisThing() 'Replace this with
'either of the bottom functions
Loop
End Sub
Private Sub PauseThisThingThatWorks()
'It works with this code:
'On the Timer event, I call
'the FunctionThatChecksTheNumberOfThreads()
'to see if I can close the form.
'(and hence continue with the program)
Dim wf As WaitForm = New WaitForm
wf.ShowDialog()
End Sub
Private Sub PauseThisThingThatDOESNOTWork()
'It doesn't work with this code for waiting
Dim RetValue as Boolean
Do
System.Threading.Thread.CurrentThread.Sleep(1000)
RetValue = FunctionThatChecksTheNumberOfThreads()
Loop Until RetValue
End Sub
End Module
.................................................................
Posted via TITANnews - Uncensored Newsgroups Access-=Every Newsgroup - Anonymous, UNCENSORED, BROADBAND Downloads=-