Beispiel #1
0
        /// <summary>
        /// Block until an emulator event occurs, asynchronous version.
        /// </summary>
        /// <param name="waitMode">What to wait for.</param>
        /// <param name="timeoutSecs">Optional timeout. This is not destructive if it fails.</param>
        /// <returns>Success/failure and failure text.</returns>
        /// <exception cref="InvalidOperationException">Session is not started.</exception>
        /// <exception cref="X3270ifCommandException"><see cref="ExceptionMode"/> is enabled and the command fails.</exception>
        /// <remarks>
        /// <note type="note">
        /// If the specified condition has already been met, <see cref="WaitAsync"/> will return immediately.
        /// See the documentation under each value of <see cref="WaitMode"/> for details on the conditions for waiting.
        /// </note>
        /// <note type="caution">
        /// The <see cref="WaitMode.Output"/> flavor of <see cref="WaitAsync"/> is integrated with the calls that
        /// read data from the screen. You must call <see cref="ReadBuffer"/>, <see cref="Ascii()"/> or <see cref="Ebcdic()"/>
        /// before a WaitAsync(WaitMode.Output) will actually wait for anything. If you
        /// Wait(WaitMode.Output) immediately after a previous WaitAsync(Output), without any intervening call to <see cref="ReadBuffer"/>,
        /// <see cref="Ascii()"/> or <see cref="Ebcdic()"/>, <see cref="WaitAsync"/> will return immediately.
        /// </note>
        /// </remarks>
        public async Task <IoResult> WaitAsync(WaitMode waitMode, int?timeoutSecs = null)
        {
            string command = "Wait(";

            if (timeoutSecs != null)
            {
                command += timeoutSecs.ToString() + ",";
            }

            var modeName = waitMode.ToString();

            if (modeName.StartsWith("Wait"))
            {
                modeName = modeName.Substring(4);
            }

            command += modeName + ")";

            return(await this.IoAsync(command, isModify : waitMode == WaitMode.Output).ConfigureAwait(continueOnCapturedContext: false));
        }