MultiThreading Of Functions:-
MultiThreading is very useful feature for program which is secure from, waiting for completion of one program or function to start second function. We can say that it is allow to work parallely with two or more function.
Let us we take a small example, here two buttons in form1 ,contain saperate functions.
In Button1 if we comment this line :-
'Dim MyThread As New System.Threading.Thread( AddressOf Mysub)
'MyThread.Start()
After run this project we are not able to click on button2 and on window ,for this we have to wait until completion of 'Mysub()' function.
If We are comment the 'Mysub()' function and comment out this code:-
'Dim MyThread As New System.Threading.Thread( AddressOf Mysub)
'MyThread.Start()
See, we can move window ,able two run Button2.
Similarly we can do same we Button2.
Public Class Form1
Public Sub Mysub()
MsgBox("Sub")
End Sub
Public Sub Mysub1()
MsgBox("Sub1")
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Mysub()
'Dim MyThread As New System.Threading.Thread( AddressOf Mysub)
'MyThread.Start()
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Mysub1()
'Dim MyThread As New System.Threading.Thread( AddressOf Mysub1)
'MyThread.Start()
End Sub
End Class
No comments:
Post a Comment