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 @@ -628,7 +628,29 @@ internal override void Dispose(bool isDisposing)
{
_cmdTransportManagers.Clear();
_closeTimeOutTimer.Dispose();

// Stop session processing thread.
try
{
_sessionMessageQueue.CompleteAdding();
}
catch (ObjectDisposedException)
{
// Object already disposed.
}

_sessionMessageQueue.Dispose();

// Stop command processing thread.
try
{
_commandMessageQueue.CompleteAdding();
}
catch (ObjectDisposedException)
{
// Object already disposed.
}

_commandMessageQueue.Dispose();
}
}
Expand Down Expand Up @@ -683,10 +705,6 @@ private void OnCloseSessionCompleted()
// stop timer
_closeTimeOutTimer.Change(Timeout.Infinite, Timeout.Infinite);

// Stop protocol message processing threads.
_sessionMessageQueue.CompleteAdding();
_commandMessageQueue.CompleteAdding();

RaiseCloseCompleted();
CleanupConnection();
}
Expand Down Expand Up @@ -753,17 +771,25 @@ private Guid GetMessageGuid(string data)

protected void HandleOutputDataReceived(string data)
{
// Route protocol message based on whether it is a session or command message.
// Session messages have empty Guid values.
if (Guid.Equals(GetMessageGuid(data), Guid.Empty))
try
{
// Session message
_sessionMessageQueue.Add(data);
// Route protocol message based on whether it is a session or command message.
// Session messages have empty Guid values.
if (Guid.Equals(GetMessageGuid(data), Guid.Empty))
{
// Session message
_sessionMessageQueue.Add(data);
}
else
{
// Command message
_commandMessageQueue.Add(data);
}
}
else
catch (InvalidOperationException)
{
// Command message
_commandMessageQueue.Add(data);
// This exception will be thrown by the BlockingCollection message queue objects
// after they have been closed.
}
}

Expand Down