public void SimulateMailArrived(string from, string to, string subj, string body) { MailEventArgs args = new MailEventArgs() { Body = body, From = from, Subject = subj, To = to }; MailArrived?.Invoke(this, args); /* * EQUIVALENTE A : * if (MailArrived !=null) * { * MailArrived(this, args); * /*EQUIVALENTE A * foreach (var item in MailArrived.GetInvocationList().ToList()) * { * MailEventHandler mm_eh = (MailEventHandler)item; * mm_eh(this, args); * } * * } */ }
protected virtual void OnMailArrived(Object sender, MailArrivedEventArgs e) { if (MailArrived != null) { MailArrived.Invoke(sender, e); } }
protected virtual void OnMailArrived(MailArrivedEventArgs args) { MailArrived?.Invoke(this, args); }
protected virtual void OnMailArrived(MailArrivedEventArgs e) { //Awesome. MailArrived?.Invoke(this, e); }