Пример #1
0
        public void OneShotRaceTest()
        {
#if INTEGRATION_TEST
            for (int condition = 0; condition < 9; condition++)
            {
                // Create timer, set to some interval
                LargeIntervalTimer lit = new LargeIntervalTimer();
                lit.Interval = TimeSpan.FromSeconds(17);

                lit.OneShot = true;
                lit.Enabled = true;

                lit.Enabled = false;

                lit.OneShot = false;
                lit.Enabled = true;

                Thread.Sleep((int)lit.Interval.TotalMilliseconds + 3000);

                Assert.IsTrue(lit.Enabled);
                Assert.IsFalse(lit.OneShot);
                lit.Dispose();
            }
#else
            Assert.Inconclusive("INTEGRATION_TEST not defined - test not run");
#endif
        }
Пример #2
0
        public void ThreadCountTest()
        {
#if INTEGRATION_TEST
            for (int condition = 0; condition < 9; condition++)
            {
                // Create timer, set to some interval
                LargeIntervalTimer lit = new LargeIntervalTimer();
                lit.Interval      = TimeSpan.FromSeconds(20);
                lit.OneShot       = true;
                lit.TestCondition = condition;

                for (int i = 0; i < 10; ++i)
                {
                    lit.Enabled = false;
                    lit.Enabled = true;
                    Thread.Sleep(0);
                }

                Assert.IsTrue(lit.ThreadCount == 1);
                Assert.IsTrue(lit.OneShot);

                lit.Dispose();
            }
#else
            Assert.Inconclusive("INTEGRATION_TEST not defined - test not run");
#endif
        }
        private void Dispose(bool ADisposing)
        {
            if (!m_Disposed)
            {
                // wenn true, alle managed und unmanaged resources mussen aufgelegt werden.
                if (ADisposing)
                {
                    //nix zu machen in moment
                }

                //Console.WriteLine("{0}: GPS-Thread beendet", DateTime.Now);

                lock (m_Lock)
                {
                    if (null != m_Thread)
                    {
                        m_StopThread = true;
                        m_Thread.Join();

                        Logger.Log("Thread {0} Stopped", m_Thread.ManagedThreadId);

                        m_Thread = null;
                    }

                    if (null != m_Timer)
                    {
                        m_Timer.Enabled = false;
                        Thread.Sleep(1000);
                        m_Timer.Dispose();
                        m_Timer = null;

                        Logger.Log("Timer Disposed");
                    }

                    m_CellCollection.Clear();
                    m_CellCollection = null;

                    Logger.Log("Cell Collection cleared");

                    if (null != m_StreamWriter)
                    {
                        m_StreamWriter.Flush();
                        m_StreamWriter.Close();
                        m_StreamWriter.Dispose();

                        Logger.Log("StreamWriter Closed and Disposed");
                    }

                    m_StreamWriter = null;
                }

                m_Lock = null;
            }

            m_Disposed = true;
        }