summaryrefslogtreecommitdiff
path: root/CSharp/Ivy/IvyPPC/Ivy.cs
diff options
context:
space:
mode:
authorfcolin2007-02-01 09:54:21 +0000
committerfcolin2007-02-01 09:54:21 +0000
commitf1132b8413eedc330a63a990014c872043e8e526 (patch)
tree38926b30bca1490578d826c021483084c1cada64 /CSharp/Ivy/IvyPPC/Ivy.cs
parent37d6c91f90d2c952c772ea4ea013f16d91edadef (diff)
downloadivy-csharp-f1132b8413eedc330a63a990014c872043e8e526.zip
ivy-csharp-f1132b8413eedc330a63a990014c872043e8e526.tar.gz
ivy-csharp-f1132b8413eedc330a63a990014c872043e8e526.tar.bz2
ivy-csharp-f1132b8413eedc330a63a990014c872043e8e526.tar.xz
Utilisateur : Fcolin Date : 11/11/03 Heure : 20:54 Archivé dans $/EScribe/Ivy Commentaire: (vss 12)
Diffstat (limited to 'CSharp/Ivy/IvyPPC/Ivy.cs')
-rw-r--r--CSharp/Ivy/IvyPPC/Ivy.cs33
1 files changed, 16 insertions, 17 deletions
diff --git a/CSharp/Ivy/IvyPPC/Ivy.cs b/CSharp/Ivy/IvyPPC/Ivy.cs
index 56aa68c..b4a2ef4 100644
--- a/CSharp/Ivy/IvyPPC/Ivy.cs
+++ b/CSharp/Ivy/IvyPPC/Ivy.cs
@@ -195,6 +195,7 @@ namespace IvyBus
watchers.Add(watcher);
}
serverThread = new Thread(new ThreadStart(this.Run));
+ serverThread.Name = "Ivy Tcp Server Thread";
serverThread.Start();
// sends the broadcasts and listen to incoming connexions
for (int i = 0; i < watchers.Count; i++)
@@ -239,10 +240,12 @@ namespace IvyBus
try
{
// stopping the serverThread
- Thread t = serverThread;
- serverThread = null;
- if (t != null)
- t.Interrupt();
+ if (serverThread != null)
+ {
+ app.Stop();
+ serverThread.Join();
+ serverThread = null;
+ }
// The serverThread might be stopped even before having been created
if (app != null)
app.Stop();
@@ -254,18 +257,20 @@ namespace IvyBus
}
// stopping the remaining IvyClients
// copy the values in temporary variable to eliminate Thread modifying collection
- IvyClient[] copyClient;
- copyClient = new IvyClient[clients.Count];
- lock( clients.SyncRoot )
+ if ( clients.Count != 0 )
{
- clients.Values.CopyTo( copyClient,0 );
- }
- foreach (IvyClient client in copyClient )
+ IvyClient[] copyClient;
+ copyClient = new IvyClient[clients.Count];
+ lock( clients.SyncRoot )
+ {
+ clients.Values.CopyTo( copyClient,0 );
+ }
+ foreach (IvyClient client in copyClient )
{
client.close(true); // will notify the reading thread
//removeClient(client); already donne in the thread
}
-
+ }
}
catch (IOException e)
{
@@ -603,12 +608,6 @@ namespace IvyBus
Console.Out.WriteLine("Ivy server socket reader caught an exception " + e.Message);
// e.printStackTrace();
}
- catch (ThreadInterruptedException te)
- {
- Console.Error.WriteLine( te.Message );
- Console.Error.WriteLine( te.StackTrace);
- running = false;
- }
catch (SocketException e)
{
traceDebug("my server socket has been closed");