Skip to content

Commit

Permalink
Merge pull request mtconnect#2 from NLandry91/master
Browse files Browse the repository at this point in the history
Fixed thread exception issue for MTCAdapter class
  • Loading branch information
William Sobel authored Apr 28, 2017
2 parents 44ba2ab + 1d4d040 commit 85700ab
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/MTCAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ private void ListenForClients()
clientThread.Start(client);

SendAllTo(client.GetStream());
clientThread.Join();
}
}
catch (Exception e)
Expand Down Expand Up @@ -562,17 +563,17 @@ public void Stop()
{
if (mRunning) {
mRunning = false;
mListener.Stop();

// Wait 2 seconds for the thread to exit.
mListenThread.Join(2*Heartbeat);

foreach (Object obj in mClients)
{
Stream client = (Stream)obj;
client.Close();
}
mClients.Clear();

// Wait 5 seconds for the thread to exit.
mListenThread.Join(2000);

// Wait for all client threads to exit.
mActiveClients.Wait(2000);
}
Expand Down

0 comments on commit 85700ab

Please sign in to comment.