CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15

Threaded View

  1. #1
    Join Date
    Nov 2000
    Posts
    154

    [RESOLVED] worker thread to fire events in COM?

    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..
    Code:
     
    //C++ header
    
    __interface _ITestEvents 
    {
    	[id(1), helpstring("method MyEvent"), source] HRESULT MyEvent([in] SHORT size,   [in, satype(byte)] SAFEARRAY * byData);
    
    }
    The event is fired when needed..
    Code:
     
    //C++ source
    
    {
    	//...
    	Long lVal = MyEvent(size, byData);
    }
    The C# client receives the event successfully ( lVal is zero ).

    Code:
    //C#
    
    m_ComObj.MyEvent += new TestCom._ITestEvents_MyEventEventHandler(OnMyEvent);
    ///......
    void OnMyEvent(short size, System.Array data)
    {
          txtBox1.Text = "received event";
    }
    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 ).

    Why I can’t use a worker thread to fire an event?
    Last edited by asinro; July 15th, 2008 at 05:42 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured