Ejemplo n.º 1
0
        public List <QueuedInput> GetInputQueue()
        {
            QueueLock.WaitOne();
            var r = Queued;

            Queued = new List <QueuedInput>();
            QueueLock.ReleaseMutex();
            return(r);
        }
Ejemplo n.º 2
0
        public override void Construct()
        {
            Root.RegisterForUpdate(this);

            OnUpdate = (sender, time) =>
            {
                MessageLock.WaitOne();
                if (NeedsInvalidated)
                {
                    this.Invalidate();
                }
                NeedsInvalidated = false;
                MessageLock.ReleaseMutex();
            };
        }
Ejemplo n.º 3
0
        public override void Construct()
        {
            Root.RegisterForUpdate(this);

            OnUpdate = (sender, time) =>
            {
                MessageLock.WaitOne();
                if (NeedsInvalidated)
                {
                    this.Invalidate();
                }
                NeedsInvalidated = false;
                MessageLock.ReleaseMutex();
            };

            Lines.Add("");

            TextGrid = AddChild(new TextGrid
            {
                AutoLayout = AutoLayout.DockFill,
                Font       = "monofont",
                TextSize   = GameSettings.Default.ConsoleTextSize,
            }) as TextGrid;
        }
Ejemplo n.º 4
0
        /*Mutex.WaitOne(TimeSpan, Boolean)封鎖目前的執行緒,直到目前的執行個體收到通知為止;
         * 使用 TimeSpan 來測量時間間隔,並指定要不要在等候之前先離開同步領域。*/
        /// <summary>
        /// 判断是否被锁定
        /// </summary>
        /// <returns></returns>
        private static bool IsFirstInstance()
        {
            // create a new instance of the Mutex class ..
            __Mu = new global::System.Threading.Mutex(false, AssemblyInfoClass.GuidInfo);

            //检查当前线程是否被锁定 check current thread whether were locking ..
            if (__Mu.WaitOne(TimeSpan.Zero, false))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }