EventArgsExtensions.cs 516 B

1234567891011121314151617181920
  1. using System;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4. namespace SIASUN.Autopilot.EventMessage
  5. {
  6. public static class EventArgsExtensions
  7. {
  8. public static void Raise<TEventArgs>(this TEventArgs e,
  9. Object sender, ref EventHandler<TEventArgs> eventDelegate)
  10. {
  11. EventHandler<TEventArgs> temp = Volatile.Read(ref eventDelegate);
  12. if (temp != null)
  13. {
  14. Task.Run(()=> { temp(sender, e); });
  15. }
  16. }
  17. }
  18. }