Execute.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. namespace Caliburn.Micro.Core {
  2. using System;
  3. using System.Threading.Tasks;
  4. /// <summary>
  5. /// Enables easy marshalling of code to the UI thread.
  6. /// </summary>
  7. public static class Execute {
  8. /// <summary>
  9. /// Indicates whether or not the framework is in design-time mode.
  10. /// </summary>
  11. public static bool InDesignMode {
  12. get {
  13. return PlatformProvider.Current.InDesignMode;
  14. }
  15. }
  16. /// <summary>
  17. /// Executes the action on the UI thread asynchronously.
  18. /// </summary>
  19. /// <param name="action">The action to execute.</param>
  20. public static void BeginOnUIThread(this Action action) {
  21. PlatformProvider.Current.BeginOnUIThread(action);
  22. }
  23. /// <summary>
  24. /// Executes the action on the UI thread asynchronously.
  25. /// </summary>
  26. /// <param name = "action">The action to execute.</param>
  27. public static Task OnUIThreadAsync(this Action action) {
  28. return PlatformProvider.Current.OnUIThreadAsync(action);
  29. }
  30. /// <summary>
  31. /// Executes the action on the UI thread.
  32. /// </summary>
  33. /// <param name = "action">The action to execute.</param>
  34. public static void OnUIThread(this Action action) {
  35. PlatformProvider.Current.OnUIThread(action);
  36. }
  37. }
  38. }