summaryrefslogtreecommitdiff
path: root/CSharp
diff options
context:
space:
mode:
authorfcolin2007-02-01 09:46:25 +0000
committerfcolin2007-02-01 09:46:25 +0000
commited5318f7fcb1540c1b9be9f3f66b02ac8ee2d2b1 (patch)
tree122b08f1c0fd30de95dee0f1ecd988c587f8bdea /CSharp
parent3b7c1a2a262a67d7fee4e259ea9ade236f2be253 (diff)
downloadivy-csharp-ed5318f7fcb1540c1b9be9f3f66b02ac8ee2d2b1.zip
ivy-csharp-ed5318f7fcb1540c1b9be9f3f66b02ac8ee2d2b1.tar.gz
ivy-csharp-ed5318f7fcb1540c1b9be9f3f66b02ac8ee2d2b1.tar.bz2
ivy-csharp-ed5318f7fcb1540c1b9be9f3f66b02ac8ee2d2b1.tar.xz
Utilisateur : Fcolin Date : 14/11/03 Heure : 14:12 Archivé dans $/EScribe/Ivy Commentaire: (vss 15)
Diffstat (limited to 'CSharp')
-rw-r--r--CSharp/Ivy/Ivy/IvyClient.cs40
1 files changed, 28 insertions, 12 deletions
diff --git a/CSharp/Ivy/Ivy/IvyClient.cs b/CSharp/Ivy/Ivy/IvyClient.cs
index 31ccdd5..360c9b1 100644
--- a/CSharp/Ivy/Ivy/IvyClient.cs
+++ b/CSharp/Ivy/Ivy/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: