Skip to content

Commit

Permalink
Avoid thread join without timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin-Molinero committed May 9, 2024
1 parent dd264cf commit 7dc7525
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,7 @@ private bool DownloadAccount()
/// </summary>
public override void Disconnect()
{
Log.Trace("InteractiveBrokersBrokerage.Disconnect(): Starting");
try
{
if (_client != null && _client.ClientSocket != null && _client.Connected)
Expand All @@ -1142,9 +1143,13 @@ public override void Disconnect()
if (_messageProcessingThread != null)
{
_signal.issueSignal();
_messageProcessingThread.Join();
if (!_messageProcessingThread.Join(TimeSpan.FromSeconds(30)))
{
Log.Error("InteractiveBrokersBrokerage.Disconnect(): timeout waiting for message processing thread to end");
}
_messageProcessingThread = null;
}
Log.Trace("InteractiveBrokersBrokerage.Disconnect(): ended");
}

/// <summary>
Expand Down

0 comments on commit 7dc7525

Please sign in to comment.