public void BasicThreadQueue() { ThreadDispatcher dispatcher = new ThreadDispatcher(); // test CreateQueue - succeeds IActionQueue queue = dispatcher.CreateQueue(); Assert.IsNotNull(queue); // test queuing an action counter = 0; queue.Enqueue(() => { IncrementCounter(Thread.CurrentThread.ManagedThreadId); }); queue.Enqueue(() => { IncrementCounter(Thread.CurrentThread.ManagedThreadId); }); // spin until counter updates while (counter < 2) { Thread.Sleep(0); } // check if a thread failed Assert.IsFalse(failed); // close things out dispatcher.Dispose(); }
public void Close() { QuixConsole.WriteLine("Closing Simulator"); collidableMaterials.Dispose(); objects.Clear(); objectsHandlers.Clear(); staticObjectsHandlers.Clear(); //Simulation.Bodies.Dispose(); // Simulation.Statics.Dispose(); Simulation.Dispose(); bufferPool.Clear(); ThreadDispatcher.Dispose(); //OnContactListeners.Clear(); // OnStaticContactListeners.Clear(); connectionState.Dispose(); //server.isRunning = false; Disposed = true; gameLoop.Stop(); //Dispose(); }
protected override void OnComboBoxDropDownClosed(object sender, EventArgs e) { ThreadDispatcher backgroundThreadP = this.backgroundThread; if (backgroundThreadP != null) { this.backgroundThread = null; backgroundThreadP.Enqueue(QueueSide.Front, () => backgroundThreadP.Dispose()).Observe(); } DisposableUtil.Free <System.Windows.Forms.Timer>(ref this.clearCacheTimer); this.clearCacheTimer = new System.Windows.Forms.Timer(); this.clearCacheTimer.Interval = (int)clearCacheDelay.TotalMilliseconds; this.clearCacheTimer.Tick += new EventHandler(this.OnClearCacheTimerTick); this.clearCacheTimer.Enabled = true; base.OnComboBoxDropDownClosed(sender, e); }