Hi..
There's a C++ COM-server (runs as a service), & a C# COM-client.
In COM server, an event is implemented as shown below..
The event is fired when needed..Code://C++ header __interface _ITestEvents { [id(1), helpstring("method MyEvent"), source] HRESULT MyEvent([in] SHORT size, [in, satype(byte)] SAFEARRAY * byData); }
The C# client receives the event successfully ( lVal is zero ).Code://C++ source { //... Long lVal = MyEvent(size, byData); }
As a multi-threaded requirement is needed I’ve created a thread using "CreateThread". In the thread function if I fire the same event, the C# client doesn’t receive it ( lVal is always non-zero ).Code://C# m_ComObj.MyEvent += new TestCom._ITestEvents_MyEventEventHandler(OnMyEvent); ///...... void OnMyEvent(short size, System.Array data) { txtBox1.Text = "received event"; }
Why I can’t use a worker thread to fire an event?




Reply With Quote