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); } }
/// <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(); }
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."); } }
/// <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; }
/// <summary> /// Disconnects this client. /// </summary> public void Disconnect() { heartBeatFunc.Stop(); connection.Disconnect(); }