|
-
Apr 15th, 2008, 04:46 PM
#1
Thread Starter
Lively Member
[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
Last edited by goldenix; Apr 15th, 2008 at 05:49 PM.

M.V.B. 2008 Express Edition
-
Apr 15th, 2008, 05:15 PM
#2
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.
-
Apr 15th, 2008, 05:49 PM
#3
Thread Starter
Lively Member
Re: [2008]Question about multithreading
 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.

M.V.B. 2008 Express Edition
-
Apr 15th, 2008, 05:50 PM
#4
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.
-
Apr 15th, 2008, 06:49 PM
#5
Thread Starter
Lively Member
Re: [Resolved][2008]Question about multithreading
 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.

M.V.B. 2008 Express Edition
-
Apr 15th, 2008, 08:15 PM
#6
Frenzied Member
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
-
Apr 16th, 2008, 07:34 AM
#7
Thread Starter
Lively Member
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.

M.V.B. 2008 Express Edition
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|