コード例 #1
0
        /// <summary>
        /// Start the next available G/M/T-code and wait until this code may finish
        /// </summary>
        /// <returns>Awaitable disposable</returns>
        private AwaitableDisposable <IDisposable> WaitForFinish()
        {
            if (!Flags.HasFlag(CodeFlags.Unbuffered))
            {
                StartNextCode();
            }

            if (Interception.IsInterceptingConnection(SourceConnection))
            {
                return(new AwaitableDisposable <IDisposable>(Task.FromResult <IDisposable>(null)));
            }

            AwaitableDisposable <IDisposable> finishTask = (Macro == null) ? _codeFinishLocks[(int)Channel, (int)_codeType].LockAsync(CancellationToken) : Macro.WaitForCodeFinish();

            return(finishTask);
        }