473,394 Members | 4,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

threading problem while creating COM objects

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.
Jul 21 '05 #1
1 1252
System.Windows.Forms.Application.DoEvents() was what i was looking for...

"Tristan Ludowyk" <tristan00au_AT_yahoo_DOT_NOSPAM_com> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
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.

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: comp.lang.php | last post by:
I've heard numerous and varied commentaries here and on other fora regarding PHP and the concept of threads. Coming from a Java background I understand how threads benefit to prevent collisions,...
77
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
8
by: Z D | last post by:
Hello, I'm having a strange problem that is probably due to my lack of understanding of how threading & COM Interop works in a WinForms.NET application. Here's the situation: I have a 3rd...
6
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a...
13
by: RCS | last post by:
I have a UI that needs a couple of threads to do some significant processing on a couple of different forms - and while it's at it, update the UI (set textboxes, fill in listviews). I created a...
17
by: Arun Kumar | last post by:
What is wrong with this code. All i am trying to test is 3 progressbar and one button. On buttonclick i create 3 threads and each thread calls a method which in turn updates the progressbar and it...
13
by: John | last post by:
I've got some reasonably complex business logic in my C# code, in a class called by a ASP.NET page. This takes around 3-4 seconds to execute. It's not dependent on SQL calls or anything like that....
16
by: One Handed Man \( OHM - Terry Burns \) | last post by:
Sorry if this gets duplicated, but I posted it and cant see it for a long time so repost. . . I have an application which is writing to a graphics object, the main UI thread and a worker thread...
10
by: Bryce Calhoun | last post by:
Hello, First of all, this is a .NET 1.1 component I'm creating. SUMMARY ----------------------- This component that I'm creating is, for all intents and purposes, a document parser (I'm...
9
by: cgwalters | last post by:
Hi, I've recently been working on an application which does quite a bit of searching through large data structures and string matching, and I was thinking that it would help to put some of this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.