T
Tristan Ludowyk
Hi,
In my application I have a worker thread which goes and sends faxes using
winXPs FAXCOMEXLib API. When a fax is complete or fails, an event is
triggered. In this handler I save the result and remove the fax from my
list of faxes being sent. However before this i must make sure my worker
thread is not currently adding new faxes to the queue.
My solution is that the event handler signals the worker thread to sleep,
and the worker thread stops what it is doing and enters an idle loop
(sleeping for a few seconds then seeing if it can start again). Once the
worker thread is sleeping, the aforementioned event handler continues to
remove the completed fax from the list i keep and we make sure we don't have
2 threads access the list concurrently.
However this is causing problems because as part of sending a fax I have to
create a FAXCOMEXLib.FaxDocumentClass object (a COM object). What I have
found is that the constructor blocks if the event handler above is running.
And since the event handler is waiting until the other thread constructs the
object and can fall into the idle loop a dead lock occurs.
This seems to me like a problem with message pumping. I have fixed this
before in pre-.NET applications by running my own message pump until
execution can continue. How would one do this in .NET, or is it even
possible?
Thanks,
Tristan.
In my application I have a worker thread which goes and sends faxes using
winXPs FAXCOMEXLib API. When a fax is complete or fails, an event is
triggered. In this handler I save the result and remove the fax from my
list of faxes being sent. However before this i must make sure my worker
thread is not currently adding new faxes to the queue.
My solution is that the event handler signals the worker thread to sleep,
and the worker thread stops what it is doing and enters an idle loop
(sleeping for a few seconds then seeing if it can start again). Once the
worker thread is sleeping, the aforementioned event handler continues to
remove the completed fax from the list i keep and we make sure we don't have
2 threads access the list concurrently.
However this is causing problems because as part of sending a fax I have to
create a FAXCOMEXLib.FaxDocumentClass object (a COM object). What I have
found is that the constructor blocks if the event handler above is running.
And since the event handler is waiting until the other thread constructs the
object and can fall into the idle loop a dead lock occurs.
This seems to me like a problem with message pumping. I have fixed this
before in pre-.NET applications by running my own message pump until
execution can continue. How would one do this in .NET, or is it even
possible?
Thanks,
Tristan.