Enhance with multithreading!!!!

thiya

New member
Joined
Apr 22, 2005
Messages
3
Programming Experience
1-3


Hi all
This is my timer event code.Now i need to execute this in seperate thread.please any one help me to sort out these

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimReg.Tick
If TimReg.Interval = 10 Then

TimReg.Interval = 4000

End If

Call Visiblity(nxt)

If nxt = 0 Then

Randompicture(nxt)

ElseIf nxt = 1 Then

Randompicture(nxt)

ElseIf nxt = 2 Then

Randompicture(nxt)

ElseIf nxt = 3 Then

Randompicture(nxt)

ElseIf nxt = 4 Then

Randompicture(nxt)

End If

End Sub

Thanks in advance
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,322
Location
Sydney, Australia
Programming Experience
10+
You start a new thread like this:
VB.NET:
Dim newThread As Thread = New Thread(AddressOf Me.SomeProcedure)

'Set required thread properties, e.g. name, priority

newThread.Start()
Note that SomeProcedure is a procedure, i.e. does not return a value, and must have no arguments. This means that whatever data the new thread needs to access must be set in global variables first. Now you just put whatever code you require the new thread to execute into SomeProcedure.

Important! If there are blocks of code from which the same variables are accessed from inside and outside the new thread which might interfere with each other, enclose them in SyncLock blocks.
 
Top Bottom