You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
753 B

  1. using System.Threading;
  2. namespace UnityEditor.PackageManager.UI
  3. {
  4. internal class ThreadedDelay
  5. {
  6. public int Length { get; set; } // In milliseconds
  7. public bool IsDone { get; private set; }
  8. public ThreadedDelay(int length = 0)
  9. {
  10. Length = length;
  11. IsDone = false;
  12. }
  13. public void Start()
  14. {
  15. if (Length <= 0)
  16. {
  17. IsDone = true;
  18. return;
  19. }
  20. IsDone = false;
  21. Thread newThread = new Thread(() =>
  22. {
  23. Thread.Sleep(Length);
  24. IsDone = true;
  25. });
  26. newThread.Start();
  27. }
  28. }
  29. }