Ejemplo n.º 1
0
        public void PeriodCallback(object state)
        {
            SimpleTimer t     = _hash[state] as SimpleTimer;
            int         calls = 0;

            lock (_sync) {
                if (_hash.Contains(t))
                {
                    calls = (int)_hash[t];
                }
                _hash[t] = ++calls;
            }

            if (calls == 5)
            {
                t.Stop();
            }
        }
Ejemplo n.º 2
0
        public void TestDipose()
        {
            _order = new ArrayList();
            for (int i = 0; i < 100; i++)
            {
                SimpleTimer t = new SimpleTimer(Callback, i, 100 + i, 0);
                t.Start();
                if (i % 2 == 0)
                {
                    t.Stop();
                }
            }

            Thread.Sleep(500);
            foreach (int val in _order)
            {
                Assert.IsTrue(val % 2 == 1, "Even value got in...");
            }
            Assert.AreEqual(_order.Count, 50, "Should be 50 in _order");
        }