|
-
May 27th, 1999, 12:35 PM
#1
Firing an Event off from a seperate thread in an ActiveX Control.
I am creating a serial port ActiveX Control for a hardware device that we have. I have the port opened and a seperate thread watches the port for information. I have to check the CTS line to see if the device is connected or not. Well, here's the deal.. In the thread I post the message back to the main COleControl object, and that object fires off the event. If I run this control in the Control Test Container, it works just fine. No problems, no errors, the device is detected and everything runs great. If I add this to a VB application, the even never fires off when the device is added or removed from the system. I can fire off other events pretty much the same way, with the exception that they are not posted from within the external thread, it's posted from the com port object I created... I have been stumped by this for quite some time, so any clues would be appreciated....
Thanks.
Aaron
-
May 28th, 1999, 08:19 AM
#2
Re: Firing an Event off from a seperate thread in an ActiveX Control.
It's odd that your implementation doesn't work. I recently had to fire events
from a separate thread also; I used a different approach than yours. Maybe you can give it a shot:
I created a COM object with one method, and one event. The method created
a separate thread, and returned to the caller. Periodically the thread had to fire events to the container. I decided to marshal my object over to the new thread, so that the thread could fire the events itself with its pointer to the object. This seemed to work in VB. I had to remember, though, to call CoInitialize and CoUninitialize in the new thread, so I could use the COM marshaling functions.
-
May 28th, 1999, 08:19 AM
#3
Re: Firing an Event off from a seperate thread in an ActiveX Control.
It's odd that your implementation doesn't work. I recently had to fire events
from a separate thread also; I used a different approach than yours. Maybe you can give it a shot:
I created a COM object with one method, and one event. The method created
a separate thread, and returned to the caller. Periodically the thread had to fire events to the container. I decided to marshal my object over to the new thread, so that the thread could fire the events itself with its pointer to the object. This seemed to work in VB. I had to remember, though, to call CoInitialize and CoUninitialize in the new thread, so I could use the COM marshaling functions.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|