c# - Sharing Interface for event handling -


good day folks

i facing interesting scenario believe can done - escaping me on fine mechanics of it.

essentially have interface has 3 methods published client call, each of these methods need trigger event on same machine.

also, clients software installed on same machine however, communication allow draconian com interface events.

here code snippets of have started on.

the base interface code:

//***************************************************************     // name: messageeventargs // desc: class represents event arguments used various events. //***************************************************************     public class messageeventargs : system.eventargs {   public string msgcontent; }  //***************************************************************     // name: myposcom (interface backing) // desc: class containes backing code each of interface methods - work //       should done here. //***************************************************************      //***************************************************************     [guid("b751ea69-5e72-4df0-8d3b-9dfa7a7accef"),  classinterface(classinterfacetype.none)] public class myposcom : myposinterfaces.imyposcom {     // callback variable assigned pos side     imyposcallback pos_sendmsg = new myposcallback();      // event handlers fired appropriate interface trigger.  allow     // pos information , return here allow caller/source continue     // functioning.     public event system.eventhandler senddestroy;      //***************************************************************         // constructor class     //***************************************************************         public myposcom() { }      //***************************************************************         // name: destroy     // desc:      //***************************************************************         public string destroy()     {         // check confirm destroy event assigned, , if trigger it.         if (senddestroy != null)         {             // create arguments passed, in case destroy not have             // content - set null             messageeventargs msgargs = new messageeventargs();             msgargs.msgcontent = string.empty;              // execute/call delegate             senddestroy(this, msgargs);              return "destroy interface triggered: , fired senddestroy";         }         else         {             return "destroy interface triggered: failed fire senddestroy";         }     } } 

the source/caller

this code snippet demos sandbox form making call interfaces destroy method in turn supposed call senddestroy event event application.

//***************************************************************** // name: btndodestroy_click //***************************************************************** private void btndodestroy_click(object sender, eventargs e) {     tboxdesrec.text = string.empty;     string rtrnval = isbarposcom.destroy();     tboxdesrec.text = rtrnval; } 

event snippet

namespace rs_sandbox {      public partial class frmsandbox : form     {         // arposinterfaces.arposcom member variable         private arposcom eventrefs = new arposcom();          public frmsandbox()         {             initializecomponent();              this.eventrefs.senddestroy += new eventhandler(ondestroy);         }          public void ondestroy(object sender, system.eventargs msgargs)         {             // need clean destroy here             console.writeline("reached ondestroy event");             console.readkey();         }     }  } 

now logically can visualize why not working, me due potential fact both apps (sandboxes) loading own dll; hence, have single instance of dll.

any appreciated - kind regards

robert s.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -