D
David
Hi All (and Peter),
I have my WIA stuff working now with info I eventually found on the net.
I have sucessfully put it into a producer/consumer thread that Peter
mentioned earlier this month. I went to one of the sites mentioned in the
message (actually, I went to both)...
http://www.yoda.arachsys.com/csharp/threads/deadlocks.shtml
About half way down is "More monitor deadlocks" which has an example of the
producer / consumer.
I am using that, but I am finding when I close my application, it is still
running...
Basically, in my consumer thread, I have a loop...
while (AppRunning)
{
object o = queue.Consume();
// Rest of my code.
}
The AppRunning bool is set to false when I close my app, but as the consumer
is holding at the queue.Consume(); the AppRunning can never be checked.
So, here is what I am thinking...
Can I make
Queue queue = new Queue();
in the ProducerConsumer a public item? If I can, then in my close, I can
check if the queue.Count is zero and if it is, I should be able to run
Thread.Abort. I guess that I will have to loop through the queue.Count ...
while (!queue.Count = 0) until it has completed.
Alternatively, is there a better way of doing this?
As I expect the consumer to take a while to clear, I want to ensure it is
empty before it is finally destroyed.
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
I have my WIA stuff working now with info I eventually found on the net.
I have sucessfully put it into a producer/consumer thread that Peter
mentioned earlier this month. I went to one of the sites mentioned in the
message (actually, I went to both)...
http://www.yoda.arachsys.com/csharp/threads/deadlocks.shtml
About half way down is "More monitor deadlocks" which has an example of the
producer / consumer.
I am using that, but I am finding when I close my application, it is still
running...
Basically, in my consumer thread, I have a loop...
while (AppRunning)
{
object o = queue.Consume();
// Rest of my code.
}
The AppRunning bool is set to false when I close my app, but as the consumer
is holding at the queue.Consume(); the AppRunning can never be checked.
So, here is what I am thinking...
Can I make
Queue queue = new Queue();
in the ProducerConsumer a public item? If I can, then in my close, I can
check if the queue.Count is zero and if it is, I should be able to run
Thread.Abort. I guess that I will have to loop through the queue.Count ...
while (!queue.Count = 0) until it has completed.
Alternatively, is there a better way of doing this?
As I expect the consumer to take a while to clear, I want to ensure it is
empty before it is finally destroyed.
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available