コード例 #1
0
        public void PollingThread_Abort_Sleeping()
        {
            PollingThread thread;
            DateTime      start;

            arg   = null;
            count = 0;

            thread       = new PollingThread(TimeSpan.FromSeconds(0.1));
            thread.Poll += new MethodArg1Invoker(OnPollSleep);
            thread.Start(null);

            Thread.Sleep(1000);
            start = SysTime.Now;
            thread.Close(TimeSpan.FromSeconds(1));
            Assert.IsTrue(SysTime.Now - start <= TimeSpan.FromSeconds(1.1));
        }
コード例 #2
0
        public void PollingThread_Basic()
        {
            PollingThread thread;

            arg   = null;
            count = 0;

            thread       = new PollingThread(TimeSpan.FromSeconds(1));
            thread.Poll += new MethodArg1Invoker(OnPoll);
            thread.Start("Hello World");

            Thread.Sleep(5100);
            thread.Close(TimeSpan.FromSeconds(2));

            Assert.AreEqual(6, count);
            Assert.AreEqual("Hello World", arg);
        }