ContextSwitchDeadlock was detected

G

Guest

Hi,
I believe this is a framework level issue. I am not sure. Pls help me.
Developement Evn:
================
Vb.net 2005( framework 2.0)

Error:
==========
ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x1b2938 to
COM context 0x1b2aa8 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.

Regards,
Sri
 
P

Peter Duniho

Hi,
I believe this is a framework level issue. I am not sure. Pls help me.
Developement Evn:
================
Vb.net 2005( framework 2.0)

Error:
==========
ContextSwitchDeadlock was detected

When did you get the error?

I see that on a semi-regular basis if I am debugging particular kinds of
code and have been spending any significant amount of time (for example,
more than 60 seconds :) ) with the process stopped.

As near as I can tell it's a false-positive error message.

If you are seeing it in a different type of situation, particularly if you
have no good explanation for why a particular thread would remain stopped
for a minute or more, then you should look into it. Otherwise, there's
probably nothing to worry about.

(In fact, I simply disabled the error message, because if I really do have
a deadlock situation in my code somewhere, I will notice it for reasons
other than geting the MDA message).

Pete
 
G

Guest

Actually I am working on exporting and importing the data from MySql
database(thru ODBC) to SqlServer 2005(Sqlclient). I can not tell exactly
where i am getting this error. I got this error in release mode also. even i
am unable to catch that exception also. I didn't see the errors, when i ran
the exe directly.
How did you disable the errors? did you mean try..catch? Please clarify..


Regards,
Sri.
 
G

Guest

Actually I am working on exporting and importing the data from MySql
database(thru ODBC) to SqlServer 2005(Sqlclient). I can not tell exactly
where i am getting this error. I got this error in release mode also. even i
am unable to catch that exception also. I didn't see the errors, when i ran
the exe directly.
How did you disable the errors? do you mean try..catch? Please clarify..


Regards,
Sri.
 
P

Peter Duniho

Actually I am working on exporting and importing the data from MySql
database(thru ODBC) to SqlServer 2005(Sqlclient). I can not tell exactly
where i am getting this error. I got this error in release mode also.
even i
am unable to catch that exception also. I didn't see the errors, when i
ran
the exe directly.
How did you disable the errors? do you mean try..catch? Please
clarify..

The "ContextSwitchDeadlock" error is, as far as I know, _only_ available
as a "Managed Debugging Assistant". You can disable it by looking under
that section in the "Debug/Exception..." dialog box. However, you should
only ever see it when you are actually debugging. If you run your
application without the debugger, it shouldn't happen.

Are you seeing this MDA appear at times when you are not using the
debugger? If so, I'm afraid I don't have any idea of what's going on. I
didn't even realize that the MDA exceptions could happen when not using
the debugger.

Pete
 
G

Guest

Hi peter,

Thanks for the response. Yes, I can see the eror with out debugger
also(run the application using IDE in Release mode(No debug marks)). No
errors If i run the exe direct from the release folder.

Regards,
Sriman.
 
P

Peter Duniho

Hi peter,

Thanks for the response. Yes, I can see the eror with out debugger
also(run the application using IDE in Release mode(No debug marks)).

It's not clear that you understand my question.

If you run your program by using the Visual Studio IDE, then you are
running with the debugger. The debugger is attached, whether you realize
it or not.
No errors If i run the exe direct from the release folder.

In other words, without the debugger the error doesn't happen.

Now, all that said, if you are not actually interrupting your program with
the debugger or otherwise doing something that would be expected and
normally cause a thread to remain active in preference for another thread
in your application, then perhaps the error is telling you something
useful.

Note that an "expected and normal" situation might be, for example, making
a database query that takes a very long time. I don't know what sort of
query this might be, but maybe something that tries to extract all of the
data from a very large data, for example.

Only you can really decide for sure whether the error is of concern or
not, since only you can judge whether it's reasonable for your application
to remain stuck in one thread for a long time. If it's not okay, then you
should probably look closer at which threads the debugger is talking about
and why you can't switch from one to the other within the MDA's time limit.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top