Exemple #1
0
        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();
        }
Exemple #2
0
        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();
        }
Exemple #3
0
        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);
        }