Guest User

Untitled

a guest
Jul 17th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. public static void Invoke(this Dispatcher dispatcher, Action action)
  2. {
  3. dispatcher.Invoke(action, null);
  4. }
  5.  
  6. public static void Invoke<T>(this Dispatcher dispatcher, Action<T> action, T param)
  7. {
  8. dispatcher.Invoke(action, param);
  9. }
  10.  
  11. public static T Invoke<T>(this Dispatcher dispatcher, Func<T> func)
  12. where T : class
  13. {
  14. return dispatcher.Invoke(func, null) as T;
  15. }
  16.  
  17. public static void BeginInvoke(this Dispatcher dispatcher, Action action)
  18. {
  19. dispatcher.BeginInvoke(action, null);
  20. }
  21.  
  22. public static void BeginInvoke<T>(this Dispatcher dispatcher, Action<T> action, T param)
  23. {
  24. dispatcher.BeginInvoke(action, param);
  25. }
  26.  
  27. public static void BeginInvoke<T>(this Dispatcher dispatcher, Func<T> func, Action<T> closure)
  28. where T : class
  29. {
  30. var dop = dispatcher.BeginInvoke(func, null);
  31. dop.Completed += (o, e) => closure(dop.Result as T);
  32. }
Add Comment
Please, Sign In to add comment