Ejemplo n.º 1
0
        /// <summary>
        ///     Stops sending requests for updates and disconnects from the remote host.  You must call Connect() again if you wish
        ///     to re-establish a connection.
        /// </summary>
        public void Disconnect()
        {
            // Stop the worker thread.
            if (_done != null)
            {
                _done.Set();
            }

            // BUG FIX: [email protected] for UltraVNC disconnect issue
            // Request a tiny screen update to flush the blocking read
            try
            {
                _rfb.WriteFramebufferUpdateRequest(0, 0, 1, 1, false);
            }
            catch
            {
                // this may not work, as Disconnect can get called in response to the
                // VncClient raising a ConnectionLost event (e.g., the remote host died).
            }

            if (_worker != null)
            {
                _worker.Join(3000); // this number is arbitrary, just so that it doesn't block forever....
            }
            _rfb.Close();
            _rfb = null;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Stops sending requests for updates and disconnects from the remote host.  You must call Connect() again if you wish to re-establish a connection.
        /// </summary>
        public async Task Disconnect(CancellationToken ct = default)
        {
            // Stop the worker thread.
            if (done != null)
            {
                done.Set();
            }

            // BUG FIX: [email protected] for UltraVNC disconnect issue
            // Request a tiny screen update to flush the blocking read
            try {
                await rfb.WriteFramebufferUpdateRequest(0, 0, 1, 1, false, ct).ConfigureAwait(false);
            } catch {
                // this may not work, as Disconnect can get called in response to the
                // VncClient raising a ConnectionLost event (e.g., the remote host died).
            }
            if (worker != null)
            {
                worker.Join(3000);                      // this number is arbitrary, just so that it doesn't block forever....
            }
            rfb.Close();
            rfb = null;
        }