For that we will create a class lets say
public delegate void DatabaseErrorEvent(object sender, NotifyEvent e);
public class NotifyEvent :EventArgs
{
public string Msg = string.Empty;
public NotifyEvent(string Notice)
{
//
// TODO: Add constructor logic here
//
this.Msg = Notice;
}
public string msg
{
get { return Msg; }
}
public class Worker
{
public Worker()
{
//
// TODO: Add constructor logic here
//
}
public event DatabaseErrorEvent CriticalFailure;
protected virtual void OnCriticalError(NotifyEvent e)
{
if (this.CriticalFailure != null)
{
this.CriticalFailure(this, e);
}
}
public void DoWorkAndRaiseEvent( string Msg )
{
OnCriticalError(new NotifyEvent(Msg));
}
}
In another Form where we want to call
public void obj_CriticalFailure(object sender, NotifyEvent e)
{
//string s = e.Msg;
lblInfo.Text = e.Msg;
}
Loading