Esempio n. 1
0
        public static unsafe bool DebugWaitOne(this AutoResetEvent are, TimeSpan?timespan)
        {
            if (timespan == null)
            {
                are.DebugWaitOne();
                return(true);
            }
            var tms = timespan.Value.Ticks / 10000;

            while (true)
            {
                if (are.WaitOne(50))
                {
                    return(true);
                }
                tms -= 50;
                if (tms <= 0)
                {
                    return(false);
                }
                if (Thread.CurrentThread.Cpu.State->Debugging != 0)
                {
                    Kernel.DebugWait(real: false);
                }
            }
        }
Esempio n. 2
0
        public bool Wait()
        {
            var wait     = new AutoResetEvent(false);
            var canceled = false;

            Wait(_canceled => {
                canceled = _canceled;
                wait.Set();
                return(1);
            });
            wait.DebugWaitOne();
            return(canceled);
        }