public static void Reset() { lock (StaticCriticalSection) { Instances.Clear(); InitQueue.Clear(); } }
public override void Init(Action onComplete) { if (Instance != null) { Debug.Log("hmm"); } VerifyArrayIntegrity(); Instance = this; InitQueue queue = new InitQueue(onComplete); for (int i = 0; i < dataSavers.Length; i++) { if (dataSavers[i] == null) { Debug.Log("Data saver (" + ((Type)i).ToString() + ") is null."); continue; } dataSavers[i].Load(queue.Register()); } queue.MarkEnd(); }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); queue = new InitQueue(() => { //On complete for (int i = 0; i < callbacks.Count; i++) { callbacks[i](); } callbacks = null; }); for (int i = 0; i < persistentObjects.Count; i++) { if (persistentObjects[i] == null) { continue; } IPersistent manager = persistentObjects[i] as IPersistent; if (manager != null) { persistentObjects[i] = manager.DuplicationBehavior(); manager = persistentObjects[i] as IPersistent; //Init manager.Init(queue.Register()); } } queue.MarkEnd(); }
public override void Init(Action onComplete) { if (Instance != null) { Debug.Log("hmm"); } VerifyArrayIntegrity(); Instance = this; InitQueue queue = new InitQueue(onComplete); for (int i = 0; i < dataSavers.Length; i++) { dataSavers[i].Load(queue.Register()); } queue.MarkEnd(); }
public static QtProjectTracker Get(EnvDTE.Project project, string projectPath) { lock (StaticCriticalSection) { if (Instances.TryGetValue(projectPath, out QtProjectTracker tracker)) { return(tracker); } tracker = new QtProjectTracker { Project = project, ProjectPath = projectPath }; Instances[projectPath] = tracker; InitQueue.Enqueue(tracker); if (InitDispatcher == null) { InitDispatcher = Task.Run(InitDispatcherLoopAsync); } return(tracker); } }
static async Task InitDispatcherLoopAsync() { while (!QtVsToolsPackage.Instance.Zombied) { while (InitQueue.IsEmpty) { await Task.Delay(100); } if (InitQueue.TryDequeue(out QtProjectTracker tracker)) { if (InitStatus == null) { await QtVsToolsPackage.Instance.JoinableTaskFactory .SwitchToMainThreadAsync(); tracker.BeginInitStatus(); await TaskScheduler.Default; } else { await QtVsToolsPackage.Instance.JoinableTaskFactory .SwitchToMainThreadAsync(); tracker.UpdateInitStatus(0); await TaskScheduler.Default; } await tracker.InitializeAsync(); } if (InitStatus != null && (InitQueue.IsEmpty || InitStatus.UserCancellation.IsCancellationRequested)) { if (InitStatus.UserCancellation.IsCancellationRequested) { InitQueue.Clear(); } tracker.EndInitStatus(); } } }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); queue = new InitQueue(() => { //On complete for (int i = 0; i < callbacks.Count; i++) { callbacks[i](); } callbacks = null; }); for (int i = 0; i < persistentObjects.Count; i++) { if (persistentObjects[i] == null) { continue; } IPersistent manager = persistentObjects[i] as IPersistent; if (manager != null) { string name = persistentObjects[i].name; pendingObjects.Add(name); persistentObjects[i] = manager.DuplicationBehavior(); manager = persistentObjects[i] as IPersistent; Action registeration = queue.Register(); //Init manager.Init(() => { pendingObjects.Remove(name); registeration(); }); } } queue.MarkEnd(); this.DelayedCall(() => { if (!queue.IsOver) { Debug.Log("A manager is taking an abnormally long time to initialize."); for (int i = 0; i < pendingObjects.Count; i++) { Debug.Log(pendingObjects[i] + " has not called 'onComplete' yet."); } } }, 2); }
public void StartTest() { InitQueue iq = new InitQueue(); iq.Start(); }
private static void Main(string[] args) { try { Server.ConnectionString = ConfigCrawler.ConnectProduct; Server.ConnectionStringCrawler = ConfigCrawler.ConnectionCrawler; Server.LogConnectionString = ConfigCrawler.ConnectLog; InitQueue isq = new InitQueue(); isq.Start(); if (args == null || args.Length == 0) { Console.WriteLine(@"Input para:"); var readLine = Console.ReadLine(); if (readLine != null) { args = readLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); } } else { Console.WriteLine(string.Join(" ", args)); } var strPara = string.Join(" ", args); var pr = new Parameter(); pr.ParseData(strPara); Console.Title = strPara; Console.CancelKeyPress += EndApp; if (pr.TypeRun == 1) { if (string.IsNullOrEmpty(pr.Domain)) { for (var i = 0; i < pr.NumberThread; i++) { Task.Factory.StartNew(() => { var w = new WorkerMqRl(RabbitMQManager.GetRabbitMQServer(ConfigCrawler.KeyRabbitMqCrawler), pr.QueueMQ, pr.AckIm); w.StartConsume(); }); Thread.Sleep(20000); } } else { var pt = new ProductAdapter(new SqlDb(QT.Entities.Server.ConnectionString)); var token = new CancellationToken(); var wokerFn = new WSS.Core.Crawler.WorkerReload(pt.GetCompanyIDFromDomain(pr.Domain), ""); wokerFn.StartCrawler(); } } else if (pr.TypeRun == 0) { if (string.IsNullOrEmpty(pr.Domain)) { for (var i = 0; i < pr.NumberThread; i++) { var token = Source.Token; var j = i; Task.Factory.StartNew(() => { var w = new WorkerMqFn(RabbitMQManager.GetRabbitMQServer(ConfigCrawler.KeyRabbitMqCrawler), pr.QueueMQ); w.StartConsume(); }, token); Thread.Sleep(20000); } } else { var pt = new ProductAdapter(new SqlDb(QT.Entities.Server.ConnectionString)); var token = new CancellationToken(); var wokerFn = new WorkerFindNew(pt.GetCompanyIDFromDomain(pr.Domain), ""); wokerFn.StartCrawler(); } } while (true) { if (Source.IsCancellationRequested) { Thread.Sleep(10000); return; } else { Thread.Sleep(1000); } } } catch (Exception ex0) { log.Error(ex0); Console.ReadLine(); } }