[Resolved][2008]Question about multithreading
Am I doing this correctly? So always if I use this multi thing I put start & join?
Code:
Dim MyThread1 As New System.Threading.Thread(AddressOf getlinks1)
Dim MyThread2 As New System.Threading.Thread(AddressOf getlinks2)
Sub main()
MyThread1 .Start()
MyThread1 .Join()
MyThread2 .Start()
MyThread2 .Join()
End Sub
Sub getlinks1()
Dim ProcID As Integer
ProcID = Shell("getlinkcollection.exe")
End Sub
Sub getlinks2()
Dim ProcID As Integer
ProcID = Shell("getlinkcollection.exe")
End Sub
Re: [2008]Question about multithreading
Join will block the calling thread until the getlinks1/getlinks2 thread terminates. If you dont specifically want this to happen, then dont call Join.
Re: [2008]Question about multithreading
Quote:
Originally Posted by Atheist
Join will block the calling thread until the getlinks1/getlinks2 thread terminates. If you dont specifically want this to happen, then dont call Join.
So basically it put in a queue? therefore calling join is very smart idea. K thanx.
Re: [Resolved][2008]Question about multithreading
In this simple case, I dont see a reason to even use threads if you're planning on calling Join.
Re: [Resolved][2008]Question about multithreading
Quote:
Originally Posted by Atheist
In this simple case, I dont see a reason to even use threads if you're planning on calling Join.
This was simply an example. What im after is to make the code in a way so I can start a thread in my GUI(for example scanning my C drive & updating progressbar in the gui) & then i can do other stuff within the GUI (like pressing buttons etc.) without my GUI freezing to death & i need to wait until its finished doing that earlier thread.
Re: [Resolved][2008]Question about multithreading
The BackGroundWorker class or component would be much easier to use:
http://msdn2.microsoft.com/en-us/lib...undworker.aspx
Re: [Resolved][2008]Question about multithreading
k i just finished this Walkthrough: Running an Operation in the Background
& I must say I understood practically nothing & if I compare it to my sample code I would say my sample is much easier to use that this background worker. & not only easier, but also the code will be a lot smaller.