Re: mutithreading in a Winforms app with CDO

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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




.



Relevant Pages

  • Re: Help! pumping wait primitives - what is that?
    ... COM context 0x1afb98 for 60 seconds. ... processing a very long running operation without pumping Windows messages. ... CoWaitForMultipleHandles) and routinely pump messages during long running ...
    (microsoft.public.dotnet.languages.vb)
  • Re: vs2005 Debugging problem, ContextSwitchDeadlock was detected
    ... How to disable MDA? ... COM context 0x1b2aa8 for 60 seconds. ... processing a very long running operation without pumping Windows messages. ...
    (microsoft.public.dotnet.framework.clr)
  • Help! pumping wait primitives - what is that?
    ... The CLR has been unable to transition from COM context 0x1afa18 to COM ... processing a very long running operation without pumping Windows messages. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Help! pumping wait primitives - what is that?
    ... The CLR has been unable to transition from COM context 0x1afa18 to COM context 0x1afb88 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. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Yoko broke up the band
    ... specific context and manipulated a certain way, ... sounds, like, say, a toilet flush, or the background noises in 4'33", ... interesting in the context of musical art. ... Another example would be the chopped-up tape loop at the end of Sgt ...
    (rec.music.beatles)