Posted by: Sourav | October 1, 2016

Passing data to a function to be run on a different thread in a type safe manner,VB Teacher Sourav,Kolkata 09748184075


Imports System.Threading
Module Module1

Sub Main()
Console.WriteLine(“Please enter the target number”)
Dim target As Integer = Convert.ToInt32(Console.ReadLine)

Dim number As numbers = New numbers(target)

Dim t1 As Thread = New Thread(AddressOf number.printnumbers)
t1.Start()

Console.ReadLine()

End Sub

End Module

Public Class numbers
Private target As Integer
Public Sub New(ByVal target As Integer)
Me.target = target
End Sub

Public Sub printnumbers()

Dim i As Integer
For i = 1 To target
Console.WriteLine(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: