473,386 Members | 1,609 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,386 software developers and data experts.

Pause Debugger in worker thread possible?

I have code running in the debugger as I type. I press pause, and it
pauses on:

Application.Run(new myForm());

*I believe* a worker thread is in deadlock (it's in a lock, but calls
another function that tries to use the same lock). If the main thread
was deadlocked, I think the debugger would stop right on that spot.
So, I assume that it is a worker thread that is deadlocked.

Is there any way to stop the debugger into a specific thread?
Any help is greatly appreciated!!

Zytan

Apr 25 '07 #1
6 2266
"Zytan" <zy**********@gmail.comwrote in message
news:11**********************@t39g2000prd.googlegr oups.com...
>I have code running in the debugger as I type. I press pause, and it
pauses on:

Application.Run(new myForm());
That's because in that thread, that's the location within your own code
where the thread is executing. If you'd managed to break during the
processing of an event for that form, you'd see the location as something
else.
*I believe* a worker thread is in deadlock (it's in a lock, but calls
another function that tries to use the same lock). If the main thread
was deadlocked, I think the debugger would stop right on that spot.
So, I assume that it is a worker thread that is deadlocked.
A thread cannot deadlock itself. That is, if a single thread has a lock,
and then attempts to get the same lock, it will succeed on the second (and
any subsequent) attempt to get the lock.

Deadlock occurs when (for example) one thread has a lock, a second thread
has a *different* lock, and each thread attempts to get the lock that the
other thread has. In that case, neither thread can get the lock it wants,
because the other thread is holding it, and neither thread will release the
lock that the other thread wants, because each thread is waiting to get the
lock that *it* wants.
Is there any way to stop the debugger into a specific thread?
Any help is greatly appreciated!!
For many months I was dismayed that the "Debug/Threads..." menu item was
removed. I had no idea where it went! I mentioned it several times in
these newsgroups, but no one had an answer. Turns out, there's a toolbar
called "Debug Location" that allows you to select the thread you want to
debug.

You'll find a bunch of threads in there that aren't ones you explicitly
made, which makes it a little trickier to find the thread you're interested
in. But you can just click through the list of threads until you find the
thread you want (hopefully you can recognize it by the code where the thread
is stopped).

Pete

Apr 25 '07 #2
That's because in that thread, that's the location within your own code
where the thread is executing. If you'd managed to break during the
processing of an event for that form, you'd see the location as something
else.
Yes, ok. I was expecting that the debugger would know the 100% cpu
activity was in another thread, and show this, but that's silly, since
how would it really know to judge such things.
A thread cannot deadlock itself. That is, if a single thread has a lock,
and then attempts to get the same lock, it will succeed on the second (and
any subsequent) attempt to get the lock.
Yes, I resolved that myself a little while later. The TRUE bug was an
infintie loop in a worker thread.

I understand fully way the same thread can enter the same lock twice.
'lock' is to prevent different threads, not the same thread. I was
surprised by this coming from using critical sections. I shouldn't
really call 'locks' critical sections, then, since they are
different. Locks are better.
Is there any way to stop the debugger into a specific thread?
Any help is greatly appreciated!!

For many months I was dismayed that the "Debug/Threads..." menu item was
removed. I had no idea where it went! I mentioned it several times in
these newsgroups, but no one had an answer. Turns out, there's a toolbar
called "Debug Location" that allows you to select the thread you want to
debug.
Aaaaah!! You're a godsend! Thanks!!!

Hm, wait, I don't have a 'Debug Location' toolbar. I am running C#
2005 Express, is that why?
You'll find a bunch of threads in there that aren't ones you explicitly
made, which makes it a little trickier to find the thread you're interested
in. But you can just click through the list of threads until you find the
thread you want (hopefully you can recognize it by the code where the thread
is stopped).
Sure, great, thanks a lot, Pete! :)

Zytan

Apr 26 '07 #3
"Zytan" <zy**********@gmail.comwrote in message
news:11**********************@b40g2000prd.googlegr oups.com...
[...]
I understand fully way the same thread can enter the same lock twice.
'lock' is to prevent different threads, not the same thread. I was
surprised by this coming from using critical sections. I shouldn't
really call 'locks' critical sections, then, since they are
different. Locks are better.
Critical sections aren't any different. The same thread can re-enter the
same critical section as often as it wants or needs to.
[...]
Hm, wait, I don't have a 'Debug Location' toolbar. I am running C#
2005 Express, is that why?
Could very well be. I think I've still got an Express version installed on
a computer around here somewhere. If I have a moment, I'll take a look and
see if I can find the same toolbar in it. But it wouldn't surprise me to
find that they removed this very useful, but somewhat-advanced, feature from
Express.

Pete

Apr 26 '07 #4
Critical sections aren't any different. The same thread can re-enter the
same critical section as often as it wants or needs to.
It can? I had no idea.
Could very well be. I think I've still got an Express version installed on
a computer around here somewhere. If I have a moment, I'll take a look and
see if I can find the same toolbar in it. But it wouldn't surprise me to
find that they removed this very useful, but somewhat-advanced, feature from
Express.
http://msdn2.microsoft.com/en-us/library/w15yf86f.aspx
says that C# Express doesn't have it.

Zytan

Apr 26 '07 #5
"Zytan" <zy**********@gmail.comwrote in message
news:11**********************@u32g2000prd.googlegr oups.com...
>Could very well be. I think I've still got an Express version installed
on
a computer around here somewhere. If I have a moment, I'll take a look
and
see if I can find the same toolbar in it. But it wouldn't surprise me to
find that they removed this very useful, but somewhat-advanced, feature
from
Express.

http://msdn2.microsoft.com/en-us/library/w15yf86f.aspx
says that C# Express doesn't have it.
Okie doke. I won't bother to check then. :)

You *can* debug a thread in Express by explicitly putting a breakpoint in
that thread's code. I know that works, because I've done it before. But of
course you have to have some idea of where you expect the code to be when
you want to interrupt it, for that to work. And you won't be able to look
at other threads, at least not easily (if I recall, it's possible the call
stack information can still be shown from other threads if you look at the
source window where those other threads are being called).

Basically, I know that at least some minimal thread-related debugging can be
done in Express; while I haven't done it recently, I do remember doing it a
little before I got around to installing the retail version of VS2005. I do
recommend the full version though, if you anticipate doing any significant
amount of multi-thread programming. Frankly, I'm surprised at just how much
they DID leave in Express, but there are a number of significant features
missing still. It's certainly worth the price of admission for the paid
version. :)

Pete

Apr 26 '07 #6
You *can* debug a thread in Express by explicitly putting a breakpoint in
that thread's code.
Yup, I've done that before, so that will work.

Hm, you just made me think of something, maybe i could have put a
conditional breakpoint. I'll have to try that sometimes.

My real problem was that a worker thread was in an infinite loop, and
there's so many loops, i'd like to know which it was just by pressing
Pause, but I need the paid version of C# for that. I think that
feature alone is worth the money.
I do
recommend the full version though, if you anticipate doing any significant
amount of multi-thread programming. Frankly, I'm surprised at just how much
they DID leave in Express, but there are a number of significant features
missing still. It's certainly worth the price of admission for the paid
version. :)
I agree completely, thanks.

Zytan

Apr 27 '07 #7

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

Similar topics

4
by: manuel | last post by:
I've two modules: main.py and eval.py Eval.py is imported in main.py, but I've a loop in eval.py that must call a function in main.py... I can't import main.py in eval.py too, because that...
0
by: Sreedharan | last post by:
Hello everyone, I am a VC++ programmer. When i develop a multi-threaded application in C++, I prefer to use worker thread, so that the main thread and worker thread can communicate using...
8
by: Wim | last post by:
My GUI application starts a process (a console program) when the user hits Play. I would like to add an option to pause that process. The code I've added to detect if the user hit pause/unpause...
11
by: Marek | last post by:
What can I do in order to avoid first exception pause? I am sure everyone already experienced this behavior and there must be a solution. regards
5
by: Stephen Lamb | last post by:
I have a background worker thread which I start from a form's HandleCreated event that makes calls back to the form using Invoke. During shutdown the form is disposed and the background worker...
1
by: Gregory Hassett | last post by:
Hi, I have a web service called GetComputerNameAndDescription which I can call from the main thread of my app. If I call it from a separate thread, however, it hangs on the call to Invoke() -- but...
5
by: Soren S. Jorgensen | last post by:
Hi, In my app I've got a worker thread (background) doing some calculations based upon user input. A new worker thread might be invoked before the previous worker thread has ended, and I wan't...
3
by: Kevin | last post by:
Using this: http://msdn2.microsoft.com/en-us/library/3dasc8as(VS.80).aspx as an example I have a question concerning the reuse of objects. In the example 10 instances of the Fibonacci class...
12
by: Zytan | last post by:
Can I break the debugger into a worker thread? Right now, my app is freezing, and when I press pause, it stops on: Application.Run(new MyForm()); I don't know what that means. I know the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.