Exemple #1
0
        void Disconnect(bool userInitiated)
        {
            lock ( connectionLock )
            {
                heartBeatFunc.Stop();

                if (connectionCancellation != null)
                {
                    connectionCancellation.Cancel();
                    connectionCancellation.Dispose();
                    connectionCancellation = null;
                }

                if (connectionSetupTask != null)
                {
                    // though it's ugly, we want to wait for the completion of this task and keep hold of the lock
                    connectionSetupTask.GetAwaiter().GetResult();
                    connectionSetupTask = null;
                }

                // Connection implementations are required to issue the Disconnected callback before Disconnect() returns
                connection?.Disconnect(userInitiated);
                Debug.Assert(connection == null);
            }
        }
Exemple #2
0
        /// <summary>
        /// Disconnects this client.
        /// </summary>
        public void Disconnect()
        {
            heartBeatFunc.Stop();

            var cts = Interlocked.Exchange(ref connectionCancellation, null);

            if (cts != null)
            {
                cts.Cancel();
                cts.Dispose();
            }

            var task = Interlocked.Exchange(ref connectionSetupTask, null);

            if (task != null)
            {
                task.GetAwaiter().GetResult();
            }
            connection?.Disconnect();
        }
Exemple #3
0
        private protected void Disconnect(bool userInitiated)
        {
            lock ( connectionLock )
            {
                heartBeatFunc.Stop();

                if (connectionCancellation != null)
                {
                    connectionCancellation.Cancel();
                    connectionCancellation.Dispose();
                    connectionCancellation = null;
                }

                var connectionSetupTaskToWait = Interlocked.Exchange(ref connectionSetupTask, null);

                // though it's ugly, we want to wait for the completion of this task and keep hold of the lock
                connectionSetupTaskToWait?.GetAwaiter().GetResult();

                // Connection implementations are required to issue the Disconnected callback before Disconnect() returns
                connection?.Disconnect(userInitiated);
                DebugLog.Assert(connection == null, nameof(CMClient), "Connection was not released in disconnect.");
            }
        }
Exemple #4
0
        /// <summary>
        /// Cancels the ongoing smooth scroll (if any) and resets all associated vars
        /// </summary>
        private void abort_smooth_scroll()
        {
            if (smooth_scroller != null)
            {
                smooth_scroller.Stop();
            }

            if (IsScrolling)
            {/* If we are in the middle of a smooth scroll then just instant finish it */
                ScrollX     = Smooth_Scroll_Target.x;
                ScrollY     = Smooth_Scroll_Target.y;
                IsScrolling = false;
            }

            Smooth_Scroll_End_Time = -1;
            Smooth_Scroll_Distance = null;
            Smooth_Scroll_Target   = null;
        }
Exemple #5
0
        /// <summary>
        /// Disconnects this client.
        /// </summary>
        public void Disconnect()
        {
            heartBeatFunc.Stop();

            connection.Disconnect();
        }