UnityScheduler.cs 942 B

123456789101112131415161718192021222324252627282930313233343536373839
  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.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. lock (Game.Instance)
  27. {
  28. this.process = process;
  29. Init.Instance.ThreadSynchronizationContext.Post(() => { Init.Instance.Process = process; });
  30. }
  31. }
  32. }
  33. }