Use MultiThreading With Delegate Feature :
Defination of Delegate:-
In this post i discuss about Delegate feature in vb.net, You know the function pointer in
C,C++,Java.The function pointer is refer some other function, it hold a address of function.
Here i compare delegate to this(function pointer),delegates are object-oriented, type-safe,
and secured. In short, a delegate is a data structure that refers to a static method or to an
object instance, and an instance method of that object. When the delegate references an
instance method, it stores not only a reference to the method entry point, but also a
reference to the object instance for which to invoke the method.
C,C++,Java.The function pointer is refer some other function, it hold a address of function.
Here i compare delegate to this(function pointer),delegates are object-oriented, type-safe,
and secured. In short, a delegate is a data structure that refers to a static method or to an
object instance, and an instance method of that object. When the delegate references an
instance method, it stores not only a reference to the method entry point, but also a
reference to the object instance for which to invoke the method.
Some property of delegate:-
- Declaration Delegate is like a normal Procedure/Method in VB.NET which accepts a parameter but doesn’t return Sub in case of a Sub method and type in case of a Function.
- Delegate does not return any type value. Technically, a Sub delegate returns a Sub pointer but for now, keep in mind, they do not return any value.
- Delegates have only declaration, they do not have any body.
Description:-
1) Delegate accept only parameter according to your program.such as like i pass the on
string parameter see the point 1 in picture how to define(here i create delegate name
as myCallBack,myCallBack1 ) and pass the parameter.
string parameter see the point 1 in picture how to define(here i create delegate name
as myCallBack,myCallBack1 ) and pass the parameter.
2)Once we assign an address to a delegate, we can use the
function encapsulated in the delegate,see the point 2,3,firstly system check the program
that it need Invoke or not, if it require then write InvokeRequired key world.
Invoke
method to call the function encapsulated in the delegate,see the point 2,3,firstly system check the program
that it need Invoke or not, if it require then write InvokeRequired key world.
Here, in this function mysubsub and mysubsub1, we have pass the integer parameter.
Now you can pass class, object, multiple parameters and even param Arrays as parameter.
So, nothing is new here.
Now you can pass class, object, multiple parameters and even param Arrays as parameter.
So, nothing is new here.
3)In point 4,5 create a thread and start thread, holding address of Mysub,Mysub1
respectively, and Mysub call delegate method containing integer parameter. To create
this program and understand more in brief follow this link.
No comments:
Post a Comment