From 03d9ff262a599dcbd6a15f2eee54d54969a042a0 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 09:54:08 +0000 Subject: Utilisateur : Fcolin Date : 6/08/03 Heure : 17:27 Archivé dans $/EScribe/Ivy Commentaire: (vss 6) --- CSharp/Ivy/IvyPPC/Ivy.cs | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'CSharp/Ivy/IvyPPC') diff --git a/CSharp/Ivy/IvyPPC/Ivy.cs b/CSharp/Ivy/IvyPPC/Ivy.cs index 47f427b..ed4c4aa 100644 --- a/CSharp/Ivy/IvyPPC/Ivy.cs +++ b/CSharp/Ivy/IvyPPC/Ivy.cs @@ -12,6 +12,7 @@ namespace IvyBus using System.Net.Sockets; using System.Threading; using System.Configuration; + using System.Windows.Forms; /// The Main bus Class /// @@ -108,6 +109,8 @@ namespace IvyBus internal Hashtable regexp_out; internal String ready_message = null; + // for synchronous event + private Control syncControl = null; /// Readies the structures for the software bus connexion. /// /// This sample shows how to start working with Ivy. @@ -141,6 +144,10 @@ namespace IvyBus if ( debug_str != null ) debug = bool.Parse(debug_str); } + public Ivy(String name, String message, Control sync) :this( name, message ) + { + syncControl = sync; + } /// connects the Ivy bus to a domain or list of domains. /// @@ -371,23 +378,39 @@ namespace IvyBus internal void FireDirectMessage (IvyClient app, int id, string arg ) { if ( directMessageReceived != null ) - directMessageReceived( app, id, arg); + { + if ( syncControl != null ) + syncControl.Invoke( directMessageReceived, new object[]{app,id,arg}); + else directMessageReceived( app, id, arg); + } } internal void FireClientConnected (IvyClient app) { if ( clientConnected != null ) - clientConnected( app); + { + if ( syncControl != null ) + syncControl.Invoke( clientConnected, new object[]{app}); + else clientConnected( app); + } } internal void FireClientDisconnected (IvyClient app) { if ( clientDisconnected != null ) - clientDisconnected( app); + { + if ( syncControl != null ) + syncControl.Invoke( clientDisconnected, new object[]{app}); + else clientDisconnected( app); + } } internal bool FireDie (IvyClient app, int id ) { if ( dieReceived != null ) - return dieReceived( app, id); - else return false; + { + if ( syncControl != null ) + syncControl.Invoke( dieReceived, new object[]{app,id}); + else return dieReceived( app, id); + } + return false; } @@ -446,7 +469,9 @@ namespace IvyBus { throw new IvyException("(callCallback) Not regexp matching id " + key); } - callback(client, tab); + if ( syncControl != null ) + syncControl.Invoke( callback, new object[]{client,tab}); + else callback(client, tab); } private static String[] myTokenize(String s, String separator) -- cgit v1.1