A
ankurw
Hi All,
I am experiencing a frustrating issue with hooking into COM events from
a Windows service writting in C#.
I create a COM object in the service and hook into an event exposed by
the object. The event gets raised a few times (3 times on a Win2k box
and only once on a Win. 2003 box to be precise) and then simply stops.
My setup is:
1. I have a manager class (market internal) within my service.
2. The service OnStart creates an object of this class and calls the
Initialise method.
3. The Initialise method spawns a new thread (new Thread(new
ThreadStart(...)). I set the ApartmentState for this thread to STA and
start a message pump (Windows.Forms.Application.Run()) at the end of
the thread proc.
4. I instantiate the COM object on this thread and assign the reference
to a module level (static) variable defined in the manager class (ref.
#1)
I receive the event the first few events after the service starts and
then nothing. Not sure if this is some weird garbage collection issue
or what - I am completely stumped (and somewhat frustrated) right now.
Any help/pointers will be greatly appreciated.
Cheers,
Ankur
I am experiencing a frustrating issue with hooking into COM events from
a Windows service writting in C#.
I create a COM object in the service and hook into an event exposed by
the object. The event gets raised a few times (3 times on a Win2k box
and only once on a Win. 2003 box to be precise) and then simply stops.
My setup is:
1. I have a manager class (market internal) within my service.
2. The service OnStart creates an object of this class and calls the
Initialise method.
3. The Initialise method spawns a new thread (new Thread(new
ThreadStart(...)). I set the ApartmentState for this thread to STA and
start a message pump (Windows.Forms.Application.Run()) at the end of
the thread proc.
4. I instantiate the COM object on this thread and assign the reference
to a module level (static) variable defined in the manager class (ref.
#1)
I receive the event the first few events after the service starts and
then nothing. Not sure if this is some weird garbage collection issue
or what - I am completely stumped (and somewhat frustrated) right now.
Any help/pointers will be greatly appreciated.
Cheers,
Ankur