diff options
author | fcolin | 2007-02-01 09:57:51 +0000 |
---|---|---|
committer | fcolin | 2007-02-01 09:57:51 +0000 |
commit | 4223ac996d571d4e92dbcad0e238b91608d1ba81 (patch) | |
tree | 56de4d9244600de88beaa6c755be60f70924af80 /CSharp/Ivy/IvyPPC/IvyClient.cs | |
parent | 6df0d14a1bddb07d96a03a0ac166beb948ca8a4d (diff) | |
download | ivy-csharp-4223ac996d571d4e92dbcad0e238b91608d1ba81.zip ivy-csharp-4223ac996d571d4e92dbcad0e238b91608d1ba81.tar.gz ivy-csharp-4223ac996d571d4e92dbcad0e238b91608d1ba81.tar.bz2 ivy-csharp-4223ac996d571d4e92dbcad0e238b91608d1ba81.tar.xz |
Utilisateur : Fcolin Date : 14/11/03 Heure : 14:12 Archivé dans $/EScribe/Ivy Commentaire: (vss 15)
Diffstat (limited to 'CSharp/Ivy/IvyPPC/IvyClient.cs')
-rw-r--r-- | CSharp/Ivy/IvyPPC/IvyClient.cs | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/CSharp/Ivy/IvyPPC/IvyClient.cs b/CSharp/Ivy/IvyPPC/IvyClient.cs index 31ccdd5..360c9b1 100644 --- a/CSharp/Ivy/IvyPPC/IvyClient.cs +++ b/CSharp/Ivy/IvyPPC/IvyClient.cs @@ -146,8 +146,8 @@ namespace IvyBus internal IvyClient(Ivy bus, MyTcpClient socket)
{
- regexp_in = new Hashtable();
- regexp_text = new Hashtable();
+ regexp_in = Hashtable.Synchronized(new Hashtable());
+ regexp_text = Hashtable.Synchronized(new Hashtable());
appName = "Unknown";
appPort = 0;
this.bus = bus;
@@ -246,14 +246,18 @@ namespace IvyBus internal int sendMsg(String message)
{
int count = 0;
- foreach (Int32 key in regexp_in.Keys )
+ lock( regexp_in.SyncRoot )
{
- Regex regexp = (Regex) regexp_in[key];
- Match result = regexp.Match(message);
- if (result.Success)
+ IDictionaryEnumerator myEnumerator = regexp_in.GetEnumerator();
+ while ( myEnumerator.MoveNext() )
{
- send(MessageType.Msg, key, result);
- count++;
+ Regex regexp = (Regex) myEnumerator.Value;
+ Match result = regexp.Match(message);
+ if (result.Success)
+ {
+ send(MessageType.Msg, (int)myEnumerator.Key, result);
+ count++;
+ }
}
}
return count;
@@ -509,8 +513,14 @@ namespace IvyBus {
try
{
- regexp_in.Add( msgId, new Regex(regexp,RegexOptions.Compiled|RegexOptions.IgnoreCase));
- regexp_text.Add( msgId, regexp);
+ lock( regexp_in.SyncRoot )
+ {
+ regexp_in.Add( msgId, new Regex(regexp,RegexOptions.Compiled|RegexOptions.IgnoreCase));
+ }
+ lock( regexp_text.SyncRoot )
+ {
+ regexp_text.Add( msgId, regexp);
+ }
}
catch (ArgumentException e)
{
@@ -524,8 +534,14 @@ namespace IvyBus break;
case MessageType.DelRegexp:
- regexp_in.Remove(msgId);
- regexp_text.Remove( msgId );
+ lock( regexp_in.SyncRoot )
+ {
+ regexp_in.Remove(msgId);
+ }
+ lock( regexp_text )
+ {
+ regexp_text.Remove( msgId );
+ }
break;
case MessageType.EndRegexp:
|