How to Create/USE events from other DLL into our own DLL.


This resource is about creating events in a New DLL using events from other DLL. This must be useful to those who are creating new DLL's from other DLL. Find the code to Create/USE events from other DLL into our own DLL. I was creating my own DLL uisng soome other dlls.so i was in problem while using the Events from Main DLL into my Own DLL. So i find Out below solution to get Events from Main DLL into our OWN DLL.

Learn How to Create/USE events from other DLL into our own DLL.


Hello EveryOne,

I was creating my own DLL uisng soome other dlls.so i was in problem while using the Events from Main DLL into my Own DLL.

So i find Out below solution to get Events from Main DLL into our OWN DLL.



public class my_DLL
{
// This is Main Dll's Object

Main_DLL_Class class1 = new Main_DLL_Class();

// Delegate for my new event

public delegate void my_event(string user);


// Handler for my new event

public virtual event my_event event1;


// function to call my new event handler

public void on_my_event_call()
{
// assign the function to Main DLL event.

class1 .Main_event += new Main_event(on_main_event);

}

//in this function we get values in parameter
void on_main_event(string user)
{

//values are passed to my new event.

event12(user);

}


}


Now use the new DLL in some other class.
See the below code.



// This is class in which we use our New DLL and its event.

Public my_new_class()
{
//creates the object of new DLL class
my_DLL my1 = new my_DLL();

//Assign Function to New event handler
my1 .event1 += new my_DLL my_event(my1 _event1);

//Function
void my1 _event1(string userid,)
{
MessageBox.Show(userid);
}

}
}


Comments

Guest Author: Susannah13 Jan 2012

Wow, your post makes mine look feeble. More power to you!



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: