Re: mutithreading in a Winforms app with CDO
- From: "Steve Smith" <steve.a.smith@xxxxxxx>
- Date: Mon, 20 Mar 2006 15:25:46 -0800
Thanks for your feedback.
I did have an ArrayList of objects in my app, and had stored away the thread
object when it was launched, so
it was easy to add the following in my btnExit_click object:
for (int x = 0; x < mboxList.Count; x++)
{
myTestMailbox y = (myTestMailbox)mboxList[x];
System.Diagnostics.Debug.WriteLine("Joining thread : " +
x.ToString("00"));
y.theThread.Join();
}
On the first pass through the loop, the application stops on thread.Join().
After about a minute or so I get the following error:
----------------------------------------------
ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x1a1e90 to
COM context 0x1a27e8 for 60 seconds.
The thread that owns the destination context/apartment is most likely either
doing a non pumping wait or processing
a very long running operation without pumping Windows messages. This
situation generally has a negative performance
impact and may even lead to the application becoming non responsive or
memory usage accumulating continually over time.
To avoid this problem, all single threaded apartment (STA) threads should
use pumping wait primitives
(such as CoWaitForMultipleHandles) and routinely pump messages during long
running operations.
------------------------------------------------
The method that is running in each thread does not do anything specific to
terminate the thread, other than falling out of the While() loop
and calling the CDO Logoff() method to log off of the mailbox.
If you have any ideas what the problem could be I would appreciate your
feedback.
Thanks again
Steve
"Lars-Inge Tønnessen (VJ# MVP)" <http://emailme.larsinge.com> wrote in
message news:euS%23pbFTGHA.5464@xxxxxxxxxxxxxxxxxxxxxxx
Please use Join on all thread before closing the main thread.
Put the references to all the threads in e.g an arraylist and run through
the list and call the join() method on all the threads.
Make sure you don't close any threads explicitly with any close statements
on the thread. Let the threads die on it's own.
Tell us how things are going.
Regards,
Lars-Inge Tønnessen
.
- References:
- mutithreading in a Winforms app with CDO
- From: Steve Smith
- Re: mutithreading in a Winforms app with CDO
- From: Lars-Inge Tønnessen \(VJ# MVP\)
- mutithreading in a Winforms app with CDO
- Prev by Date: Cannot connect to SQLEXPRESS via MS Enterprise Library??
- Next by Date: Re: Converting string to date time
- Previous by thread: Re: mutithreading in a Winforms app with CDO
- Next by thread: Problems with Threading and CDO in C# Winforms app
- Index(es):
Relevant Pages
|