Posted by: Sourav | September 30, 2016

Threadstart Delegate ,Lambda Expression in Thread Example in VB,VB Teacher Sourav,Kolkata 09748184075


Imports System.Threading
Module Module1

Sub Main()
Dim num As number = New number

‘Dim t1 As Thread = New Thread(AddressOf number.printnumbers)
‘Dim t1 As Thread = New Thread(New ThreadStart(AddressOf number.printnumbers))
‘Dim t1 As Thread = New Thread(Sub() number.printnumbers())
Dim t1 As Thread = New Thread(Sub() number.printnumbers())

Dim t2 As Thread = New Thread(Sub() num.printnumbers2())
t1.Start()
t2.Start()
Console.ReadLine()

End Sub

End Module

Public Class number

Public Shared Sub printnumbers()
Dim i As Integer
For i = 1 To 10
Console.WriteLine(“I am in t1 thread” & i)

Next
End Sub
Public Sub printnumbers2()
Dim i As Integer
For i = 1 To 10
Console.WriteLine(“I am in t2 thread” & i)

Next
End Sub
End Class

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: