Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multithreading with Unknown Number of Processes 1

Status
Not open for further replies.

schwarem

Programmer
Apr 18, 2002
159
0
0
US
I am trying to write an application that is multithreaded. It loads a list of files and kicks off a new thread for each one. The files are displayed in a datagrid with a % complete to indicate how much has been processed. The number of files being processed is dynamic. How do I multithread a dynamic number of threads and handle the events they throw to update the progress? I can do it for one thread or a definitive number of threads, but I can't figure out how to do it for a dynamic number of threads.
 
Something like this?

Code:
private sub Button1_Click(...) handles button1.click
  for i as integer = 1 to 100
    dim del as new delMyThreadedMethod(Addressof MyThreadedMethod)
    del.begininvoke(value1, value2, nothing, nothing)
  next i
end sub


private delegate sub delMyThreadedMethod(Parm1 as object, Parm2 as object)

private sub MyThreadedMethod(Parm1 as object, Parm2 as object)
  'stuff
end sub

Just replace the for loop with a loop that goes through what ever list of files you have.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top