private async void rdpClient_OnDisconnected(
            object sender,
            IMsTscAxEvents_OnDisconnectedEvent args)
        {
            var e = new RdpDisconnectedException(
                args.discReason,
                this.rdpClient.GetErrorDescription((uint)args.discReason, 0));

            using (ApplicationTraceSources.Default.TraceMethod().WithParameters(e.Message))
            {
                LeaveFullScreen();

                if (!this.connecting && e.IsTimeout)
                {
                    // An already-established connection timed out, this is common when
                    // connecting to Windows 10 VMs.
                    //
                    // NB. The same error code can occur during the initial connection,
                    // but then it should be treated as an error.

                    this.reconnectPanel.Visible = true;
                }
                else if (e.IsIgnorable)
                {
                    Close();
                }
                else
                {
                    await ShowErrorAndClose("Disconnected", e)
                    .ConfigureAwait(true);;
                }
            }
        }
        private void rdpClient_OnAutoReconnecting2(
            object sender,
            IMsTscAxEvents_OnAutoReconnecting2Event args)
        {
            using (TraceSources.IapDesktop.TraceMethod().WithoutParameters())
            {
                var e = new RdpDisconnectedException(
                    args.disconnectReason,
                    this.rdpClient.GetErrorDescription((uint)args.disconnectReason, 0));

                TraceSources.IapDesktop.TraceVerbose(
                    "Reconnect attempt {0}/{1} - {2} - {3}",
                    args.attemptCount,
                    args.maxAttemptCount,
                    e.Message,
                    args.networkAvailable);
            }
        }
        private async void rdpClient_OnDisconnected(
            object sender,
            IMsTscAxEvents_OnDisconnectedEvent args)
        {
            var e = new RdpDisconnectedException(
                args.discReason,
                this.rdpClient.GetErrorDescription((uint)args.discReason, 0));

            using (TraceSources.IapDesktop.TraceMethod().WithParameters(e.Message))
            {
                if (e.IsIgnorable)
                {
                    Close();
                }
                else
                {
                    await ShowErrorAndClose("Disconnected", e);
                }
            }
        }