Threading
-
Hi, I wanna use threading in my application for doing this i used this code
Me.thread1 = New Threading.Thread(AddressOf Me.process1) Me.thread2 = New Threading.Thread(AddressOf Me.process2) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.thread1.Priority = ThreadPriority.Highest Me.thread2.Priority = ThreadPriority.Highest Me.thread2.Start() Me.thread1.Start() End Sub
But The problem is that when one process is completed then other process is started while i wanna start both process simultaneously... How can i do this i have searched in google but nothing find benificial Thanks with anticipationUnless u don't give ur hundred percent whatever u r doing till there is no result of ur work...
-
Hi, I wanna use threading in my application for doing this i used this code
Me.thread1 = New Threading.Thread(AddressOf Me.process1) Me.thread2 = New Threading.Thread(AddressOf Me.process2) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.thread1.Priority = ThreadPriority.Highest Me.thread2.Priority = ThreadPriority.Highest Me.thread2.Start() Me.thread1.Start() End Sub
But The problem is that when one process is completed then other process is started while i wanna start both process simultaneously... How can i do this i have searched in google but nothing find benificial Thanks with anticipationUnless u don't give ur hundred percent whatever u r doing till there is no result of ur work...
I can't see anything wrong with this bit of code. Try calling Thread.Sleep in one or both of the Threads and see what happens. This makes the Thread give way to other operations for a certain amount of time before continuing. Also, remember that unless you have multiple CPUs, a computer only ever appears to be doing multiple things at once, but instead only does one thing at a time, rapidly switching between tasks to give the illusion of multitasking. It might just be that Windows' task scheduling ends up with them being executed on at a time. You could also try lowering the Priority of both the Threads. Do they really need to have Highest priority? Tony
-
Hi, I wanna use threading in my application for doing this i used this code
Me.thread1 = New Threading.Thread(AddressOf Me.process1) Me.thread2 = New Threading.Thread(AddressOf Me.process2) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.thread1.Priority = ThreadPriority.Highest Me.thread2.Priority = ThreadPriority.Highest Me.thread2.Start() Me.thread1.Start() End Sub
But The problem is that when one process is completed then other process is started while i wanna start both process simultaneously... How can i do this i have searched in google but nothing find benificial Thanks with anticipationUnless u don't give ur hundred percent whatever u r doing till there is no result of ur work...
The code looks fine, how are you sure they are not starting at the same time?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham