Пример #1
0
        private Battle WaitForBattle(KancolleAction action)
        {
            currentBattle = null;
            actionExecutor.Execute(action);
            DateTime start = DateTime.Now;

            while (currentBattle == null && (DateTime.Now - start).TotalMilliseconds <= ActionTimeout)
            {
                Thread.Sleep(500);
            }
            return(currentBattle);
        }
Пример #2
0
        /// <summary>
        /// 线程阻塞,一直等到有response响应
        /// </summary>
        /// <returns></returns>
        private bool LockNowAndWaitForResponse(KancolleAction action)
        {
            lock (actionTimeStampLock)
            {
                currentResponse = null;
                actionTimeStamp = DateTime.Now;
            }
            actionExecutor.Execute(action);
            DateTime start = DateTime.Now;

            while ((currentResponse == null || currentResponse.Time <= actionTimeStamp) && (DateTime.Now - start).TotalMilliseconds <= ActionTimeout)
            {
                Thread.Sleep(500);
            }

            if (currentResponse != null && currentResponse.Time > actionTimeStamp)
            {
                return(true);
            }
            return(false);
        }