UnityScheduler.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.Collections.Generic;
  2. namespace ET
  3. {
  4. public class UnityScheduler: Singleton<UnityScheduler>, ISingletonScheduler
  5. {
  6. public bool IsStart;
  7. private Process process;
  8. public void StartScheduler()
  9. {
  10. Init.Instance.ThreadSynchronizationContext.Post(() => { Init.Instance.IsStart = true; });
  11. }
  12. public void StopScheduler()
  13. {
  14. Init.Instance.ThreadSynchronizationContext.Post(() => { Init.Instance.IsStart = false; });
  15. // Process Loop完成
  16. while (true)
  17. {
  18. if (process.IsRuning)
  19. {
  20. break;
  21. }
  22. }
  23. }
  24. public void Add(Process process)
  25. {
  26. this.process = process;
  27. Init.Instance.ThreadSynchronizationContext.Post(()=>{ Init.Instance.Process = process; });
  28. }
  29. public void Remove(Process process)
  30. {
  31. this.process = null;
  32. Init.Instance.ThreadSynchronizationContext.Post(()=>{ Init.Instance.Process = null; });
  33. }
  34. }
  35. }