Beispiel #1
0
        private void HandleTaskMessage(AsyncTaskMessage message)
        {
            var originalSender = Sender;

            ColorConsole.WriteOrange($"The Sender of AsyncTaskMessage is '{originalSender}'");
            DelayAndReturnZero().PipeTo(Self, originalSender);
        }
    protected override void Beat()
    {
        IInternalMessage message = SystemMessageQueue.Instance.Poll();

        if (message != null)
        {
            switch (message.GetMessageId())
            {
            case AsyncTaskMessage.ASYNC_MESSAGE_ID:
            {
                AsyncTaskMessage asyncTaskMessage = message as AsyncTaskMessage;
                AsyncState       state            = asyncTaskMessage.State;
                IAsyncTask       asyncTask        = asyncTaskMessage.AsyncTask;
                if (state == AsyncState.DoAsync)
                {
                    throw new ApplicationException(string.Format("asyncTask:{0} [DoAsyncTask] infinite loop.", asyncTask.GetType().FullName));
                }
                AsyncManager.Instance.ExecuteAsyncTask(state, asyncTask);
                break;
            }

            default:
            {
                break;
            }
            }
        }
    }