From 37d6c91f90d2c952c772ea4ea013f16d91edadef Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 09:54:18 +0000 Subject: Utilisateur : Fcolin Date : 4/11/03 Heure : 18:07 Archivé dans $/EScribe/Ivy Commentaire: (vss 11) --- CSharp/Ivy/IvyPPC/Ivy.cs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'CSharp') diff --git a/CSharp/Ivy/IvyPPC/Ivy.cs b/CSharp/Ivy/IvyPPC/Ivy.cs index 60c3ff4..56aa68c 100644 --- a/CSharp/Ivy/IvyPPC/Ivy.cs +++ b/CSharp/Ivy/IvyPPC/Ivy.cs @@ -56,6 +56,10 @@ namespace IvyBus { return debug; } + set + { + debug = value; + } } /// ClientNames accesses the name list of the connected clients @@ -137,7 +141,7 @@ namespace IvyBus { callbacks = new Hashtable(); clients = Hashtable.Synchronized( new Hashtable() ); - regexp_out = new Hashtable(); + regexp_out = Hashtable.Synchronized( new Hashtable()); appName = name; ready_message = message; String debug_str = ConfigurationSettings.AppSettings["IVY_DEBUG"]; @@ -249,14 +253,19 @@ namespace IvyBus ((IvyWatcher) watchers[i]).stop(); } // 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 ) { - foreach (IvyClient c in clients.Values ) + clients.Values.CopyTo( copyClient,0 ); + } + foreach (IvyClient client in copyClient ) { - c.close(true); // will notify the reading thread - //removeClient(c); already donne in the thread + client.close(true); // will notify the reading thread + //removeClient(client); already donne in the thread } - } + } catch (IOException e) { @@ -594,6 +603,12 @@ 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"); -- cgit v1.1