ImmediateDispatcher.cs 757 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Threading.Tasks;
  3. using Avalonia.Threading;
  4. namespace Avalonia.UnitTests
  5. {
  6. /// <summary>
  7. /// Immediately invokes dispatched jobs on the current thread.
  8. /// </summary>
  9. public class ImmediateDispatcher : IDispatcher
  10. {
  11. public bool CheckAccess()
  12. {
  13. return true;
  14. }
  15. public void InvokeAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
  16. {
  17. action();
  18. }
  19. public Task InvokeTaskAsync(Action action, DispatcherPriority priority = DispatcherPriority.Normal)
  20. {
  21. action();
  22. return Task.FromResult<object>(null);
  23. }
  24. public void VerifyAccess()
  25. {
  26. }
  27. }
  28. }