Tuesday, May 3, 2011

Callbacks using C# & DLL's


When callback is required:


1) Sample Application ---------interacts with-------> Library(dll).

2) sample Application calls certain method say STOP() of library.

3) When the task inside method STOP() is over, then if we want to make a reference to a method CALLBACK() of SampleApplication we use the concept of callbacks


To achieve this feature in visual studio using c#

we need to work with Delegates & Events.



Inside Library(.dll)


1) In class where you have created STOP method write these 2 lines:


2) Create STOP method:



Inside Sample Application


1) When user clicks any button call the STOP() method of the library


2) Recieving callback