I couldn't really implement the changes that you suggested. I'd really appreciate if you can write your changes in terms of the code I have written in my previous comment. I know it could be very trivial thing but I am not able to do that. I would really appreciate that.
Thanks..
Siddhartha
Main Topics
Browse All Topics





by: bgungorPosted on 2003-02-19 at 12:46:28ID: 7983529
Define the delegate and an event of your delegate type in Class2.
Handler);
In Class1, before you use Class2, subscribe to the event and provide a message handler.
In class 2: (setting up handler definition (delegate) and event)
public delegate MyMessageHandler(object sender, string message);
public event MyMessageHandler MyMessage();
In Class 1:
private MyHandler(object sender, string message){
// Handler function
MessageBox.Show(message);
}
private UsingClass2()
{
Class2 myClass2 = new Class2();
myClass2 += new Class2.MyMessageHandler(My
}
Then to notify class1 from Class2:
In Class 2:
public void DoingSomething()
{
MyMessage(this,"Hey, something happened");
}
Hope this helps,
Bg