Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -813,18 +813,26 @@ private void HandleReadyForDisconnect(object sender, EventArgs args)
// what thread this callback is made from. If it was made from a transport
// callback event then a deadlock may occur when DisconnectAsync is called on
// that same thread.
ThreadPool.QueueUserWorkItem(new WaitCallback(StartDisconnectAsync), RemoteSession);
ThreadPool.QueueUserWorkItem(new WaitCallback(StartDisconnectAsync));
}
}
}

/// <summary>
/// WaitCallback method to start an asynchronous disconnect.
/// </summary>
/// <param name="remoteSession"></param>
private void StartDisconnectAsync(object remoteSession)
/// <param name="state"></param>
private void StartDisconnectAsync(object state)
{
((ClientRemoteSession)remoteSession).DisconnectAsync();
var remoteSession = RemoteSession;
try
{
remoteSession?.DisconnectAsync();
}
catch
{
// remoteSession may have already been disposed resulting in unexpected exceptions.
}
}

/// <summary>
Expand Down