TestWithServicesBase.cs 609 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Avalonia.Threading;
  7. namespace Avalonia.UnitTests
  8. {
  9. public class TestWithServicesBase : IDisposable
  10. {
  11. private IDisposable _scope;
  12. public TestWithServicesBase()
  13. {
  14. _scope = AvaloniaLocator.EnterScope();
  15. }
  16. public void Dispose()
  17. {
  18. if (Dispatcher.UIThread.CheckAccess())
  19. {
  20. Dispatcher.UIThread.RunJobs();
  21. }
  22. _scope.Dispose();
  23. }
  24. }
  25. }