|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Help for VBnet ThreadMy application have two threads that run at the same time. This is my code Public WithEvents tww1 As New ThreadWrapp1 Public t1 As New Thread(AddressOf tww1.Ask) Public WithEvents tww2 As New ThreadWrapp2 Public t2 As New Thread(AddressOf tww2.ask) Public Class ThreadWrapp1 Public Event Event1 Public Sub Ask() Try Do For i = 2 To 4 ' ask status of periferal i If Condition(i)=True Then RaiseEvent Event1 End If Next i Loop Catch ex As Exception MsgBox(Err.Description) End Try End Sub End Class Public Class ThreadWrapp2 Public Event Event2 Public Sub Ask() Try Do For i = 2 To 4 ' ask status of periferal i If Condition(i)=True Then RaiseEvent Event2 End If Next i Loop Catch ex As Exception MsgBox(Err.Description) End Try End Sub End Class Private Sub tww1_Event1() Handles tww1.Event1 ' Manage status End Sub Private Sub tww2_Event2() Handles tww2.Event2 ' Manage status End Sub Sub Main t2.Start t1.Start End Sub I note that threads switch to each other very accidentally and casually, I would want they switch regolary. For example, I note this ThradWrapp1 (Condition (1)) ThradWrapp1 (Condition (2)) ThradWrapp1 (Condition (3)) ThradWrapp1 (Condition (4)) ThradWrapp1 (Condition (1)) ThradWrapp1 (Condition (2)) ThradWrapp1 (Condition (3)) ThradWrapp1 (Condition (4)) ThradWrapp2 (Condition (1)) ThradWrapp2 (Condition (2)) ThradWrapp1 (Condition (1)) ThradWrapp1 (Condition (2)) ThradWrapp1 (Condition (3)) ThradWrapp1 (Condition (4)) ThradWrapp1 (Condition (1)) ThradWrapp1 (Condition (2)) I wold want this ThradWrapp1 (Condition (1)) ThradWrapp2 (Condition (1)) ThradWrapp1 (Condition (2)) ThradWrapp2 (Condition (2)) ThradWrapp1 (Condition (3)) ThradWrapp2 (Condition (3)) ThradWrapp1 (Condition (4)) ThradWrapp2 (Condition (4)) ThradWrapp1 (Condition (1)) ThradWrapp2 (Condition (1)) ThradWrapp1 (Condition (2)) ThradWrapp2 (Condition (2)) ThradWrapp1 (Condition (3)) ThradWrapp2 (Condition (3)) ThradWrapp1 (Condition (4)) ThradWrapp2 (Condition (4)) or nearly... Thanks and sorry my bad English Gianno,
The purpose of threads is that they run completely asynchrone. When you need synchronise processes you simple would not use threads. (Don't forget that threads cost extra process time on single processor computers and not definitely will affect the time on multiprocessor computers or hyperthreading processors.). Cor
HTML Forms Progamatically Via VB.NET
Microsoft MVPs Say They Want Old VB Back Anyone tried REALbasic? ArrayList Strongly Typed Datagrid colum sorting problem - URGENT Problem with VS.NET 2003 Problem Compare Two File How to implement ComboBox.FindValue list item colour HELP! Cannot start NEW project |
|||||||||||||||||||||||