473,513 Members | 4,001 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Break debugger into worker thread?

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 application starts there.
But why would the debugger stop on it? Why doesn't it stop where the
code is being run? I think there's a worker thread that is messed up.

Zytan

Apr 26 '07 #1
12 1939
Hi Zytan,
the debugger will break there since the main UI thread will be sitting
waiting for Windows messages to process in the message loop.

Are you updating your controls using a different thread than the main UI
thread, using .Net1.1? If so this could explain your freezing.

Mark.
--
http://www.markdawson.org
"Zytan" wrote:
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 application starts there.
But why would the debugger stop on it? Why doesn't it stop where the
code is being run? I think there's a worker thread that is messed up.

Zytan

Apr 26 '07 #2
"Zytan" <zy**********@gmail.comwrote in message
news:11**********************@r35g2000prh.googlegr oups.com...
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 application starts there.
But why would the debugger stop on it? Why doesn't it stop where the
code is being run? I think there's a worker thread that is messed up.
I already answered most of this question, in reply to a different thread you
started.

The debugger didn't "stop on it"...it should be shown in green, which means
that it's simply part of the current call stack in one of your threads (in
this case, the main thread). And of course, it should be no surprise that
that line of code is part of the current call stack in one of your threads,
right? :)

When you break in the debugger, *all* threads are stopped. The debugger
shows you your main thread, but as I explained in the other post, you have
access to any thread you like. You just have to tell the debugger which one
you want to look at.

Pete

Apr 26 '07 #3
Hi Zytan,

in addition to what Mark and Peter said: Open the threads window. There you
con switch between all threads. You can help to recognice your thread by
setting the Name property of the thread in code. This name will be shown in
the list.

Christof
Apr 26 '07 #4
Are you updating your controls using a different thread than the main UI
thread, using .Net1.1? If so this could explain your freezing.
It was an infinite loop, haha!

Zytan

Apr 26 '07 #5
I already answered most of this question, in reply to a different thread you
started.
Sorry for that. Google groups was not working, and I didn't think my
posts were being made. Then I seen new posts appearing, without mine,
so I posted again.
The debugger didn't "stop on it"...it should be shown in green, which means
that it's simply part of the current call stack in one of your threads (in
this case, the main thread). And of course, it should be no surprise that
that line of code is part of the current call stack in one of your threads,
right? :)
Yes, it shows in green. I've replicated my infinite loop just to test
this out. So, this main thread is just not doing anything (other than
handling UI info in the message loop that we cannot see), which is why
it shows on Application.Run, which is the lowest part of the call
stack for this main UI thread. Did I get it right? :)
When you break in the debugger, *all* threads are stopped.
Oh, I was under the impression that the others continued. How about
socket threads that are made from using Sockets? They must stop as
well, right?
The debugger
shows you your main thread, but as I explained in the other post, you have
access to any thread you like. You just have to tell the debugger which one
you want to look at.
Unfortunately, I cannot find out how to do this in C# 2005 Express...
but thanks for your help!

Zytan

Apr 26 '07 #6
in addition to what Mark and Peter said: Open the threads window. There you
con switch between all threads. You can help to recognice your thread by
setting the Name property of the thread in code. This name will be shown in
the list.
http://msdn2.microsoft.com/en-us/lib...6f(VS.80).aspx
C# - Express Edition - No

Damn! It's not included in Express......

Zytan

Apr 26 '07 #7
Express edition doesn't have threads window? That's very bad, if you have to
debug multethreaded applications in C# Express edition. :-(

Then I can't see any way to switch the thread in the debugger. The only way
I can think of is putting a breakpoint somewhere where the worker thread (or
wich ever you want to debug), will come by.
Just an idea ;-)

Christof
Apr 26 '07 #8
"Zytan" <zy**********@gmail.comwrote in message
news:11*********************@c18g2000prb.googlegro ups.com...
>I already answered most of this question, in reply to a different thread
you
started.

Sorry for that. Google groups was not working, and I didn't think my
posts were being made. Then I seen new posts appearing, without mine,
so I posted again.
As a point of information:

As is the case with all newsgroups, this newsgroup is accessed via NNTP
servers (even using Google Groups, the back-end is NNTP), and NNTP servers
do not generally display submitted posts immediately. Depending on the
server and the current load, a post could take minutes or even hours to show
up. With direct access to the NNTP server, hours is pretty rare, but Google
doesn't provide you with direct access to the NNTP server and I've noticed
it can take longer for posts to show up there.

Patience is a virtue. :)
Yes, it shows in green. I've replicated my infinite loop just to test
this out. So, this main thread is just not doing anything (other than
handling UI info in the message loop that we cannot see), which is why
it shows on Application.Run, which is the lowest part of the call
stack for this main UI thread. Did I get it right? :)
Depending on the code you've written for the main form, it's possible to
manage to break just at the right moment when your code for that form is
executing. In that case, the debugger would show your execution location in
yellow at the actual point of execution.

Of course, if you set a break point or call the "debug break" method
explicitly in the main form's code, then you are assured of breaking in that
main thread, in the code you've written.

Also, it's not really so much that the call to Application.Run() is the
"lowest part of the call stack" for that thread. It just happens to be the
lowest part that is in *your* code. The thread is actually executing deeper
down than that, which is in fact why the location is green rather than
yellow. If you had the source and a PDB for the code that was executing (in
the system code in this case), the debugger would have shown you that code
(and it will when the code happens to be your own, since in that case you
*do* have the source and a PDB for it).
>When you break in the debugger, *all* threads are stopped.

Oh, I was under the impression that the others continued. How about
socket threads that are made from using Sockets? They must stop as
well, right?
Yes, every thread in the process stops. A corallary to this is that when
you use a "step" command in the debugger, every thread gets to run as well
*but* you only get to control line-by-line the thread you're looking at.
This can produce some challenging "debugging-only" scenarios in buggy
multi-threaded code. :)

Pete

Apr 26 '07 #9
As is the case with all newsgroups, this newsgroup is accessed via NNTP
servers (even using Google Groups, the back-end is NNTP), and NNTP servers
do not generally display submitted posts immediately. Depending on the
server and the current load, a post could take minutes or even hours to show
up. With direct access to the NNTP server, hours is pretty rare, but Google
doesn't provide you with direct access to the NNTP server and I've noticed
it can take longer for posts to show up there.
Ok, thanks. I thought I had waited a day, but it may have been the
same day only hours later. I'm doing so many things at once, I
forget. Also, I thought google had not accepted a post of mine
before. But, now that I think of it, it was just delayed, too, about
a day.
Depending on the code you've written for the main form, it's possible to
manage to break just at the right moment when your code for that form is
executing. In that case, the debugger would show your execution location in
yellow at the actual point of execution.
Yes, it shows as yellow, I just tried it. I never noticed the color
difference before. So, green means code that is NOT currently being
run. Ok.
Also, it's not really so much that the call to Application.Run() is the
"lowest part of the call stack" for that thread. It just happens to be the
lowest part that is in *your* code. The thread is actually executing deeper
down than that, which is in fact why the location is green rather than
yellow. If you had the source and a PDB for the code that was executing (in
the system code in this case), the debugger would have shown you that code
(and it will when the code happens to be your own, since in that case you
*do* have the source and a PDB for it).
Yes, it doesn't bother me with the inner details of the .NET code, it
shows me only my own stuff.
Oh, I was under the impression that the others continued. How about
socket threads that are made from using Sockets? They must stop as
well, right?

Yes, every thread in the process stops. A corallary to this is that when
you use a "step" command in the debugger, every thread gets to run as well
*but* you only get to control line-by-line the thread you're looking at.
This can produce some challenging "debugging-only" scenarios in buggy
multi-threaded code. :)
I can imagine, wow. Thanks for the information, this helps a lot! :)

Zytan

Apr 26 '07 #10
At least next time I'll know to check for infinite loops.. :)

Zytan

Apr 26 '07 #11
"Zytan" <zy**********@gmail.comwrote in message
news:11*********************@r30g2000prh.googlegro ups.com...
[...]
>Depending on the code you've written for the main form, it's possible to
manage to break just at the right moment when your code for that form is
executing. In that case, the debugger would show your execution location
in
yellow at the actual point of execution.

Yes, it shows as yellow, I just tried it. I never noticed the color
difference before. So, green means code that is NOT currently being
run. Ok.
Define "currently being run". :)

When you break in the debugger, *no* code is "currently being run", since
all of the code is stopped. On the other hand, yes...when you see yellow,
that's where the actual instruction pointer is. Green shows you locations
that are in your call stack and so the instruction pointer will eventually
be returned to that location, but is currently not there.

I hope that makes sense, and is what you meant. :)

Pete

Apr 26 '07 #12
Define "currently being run". :)

:)
When you break in the debugger, *no* code is "currently being run", since
all of the code is stopped. On the other hand, yes...when you see yellow,
that's where the actual instruction pointer is. Green shows you locations
that are in your call stack and so the instruction pointer will eventually
be returned to that location, but is currently not there.

I hope that makes sense, and is what you meant. :)
This all makes perfect sense, Pete, thanks!

Zytan

Apr 27 '07 #13

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

Similar topics

2
1392
by: Fu Chen | last post by:
Hi! I have really weird break point. Look at my screen shoot http://www.mapsea.com/vs.jpg First break is normal and can stop when program run to that position. Second break show with a question symbol inside. move the mouse cursor over it. It say the break won't be hit for no runnable code associated with it. But I can stop at the first...
1
3591
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 only if I'm in the debugger. Here's a stack trace with non-user code shown -- the call to RegisterNotifySource, at the top of the stack, never...
7
2111
by: Jeff Stewart | last post by:
I need a thread to run a subroutine which updates my main form's progress bar. I've properly marshaled all UI updates to the main UI thread, and after the main thread starts the worker thread, it waits for the worker thread to complete by means of a while t.isAlive, sleep(0) mechanism. But when my worker thread calls my UpdateProgressBar...
7
2671
by: Charles Law | last post by:
My first thought was to call WorkerThread.Suspend but the help cautions against this (for good reason) because the caller has no control over where the thread actually stops, and it might have a lock pending, for example. I want to be able to stop a thread temporarily, and then optionally resume it or stop it for good.
6
5979
by: Joe Jax | last post by:
I have an object that spawns a worker thread to process one of its methods. That method processes methods on a collection of other objects. During this processing, a user may request to cancel the entire operation. I could request abort on the worker thread, but that is a) potentially messy, and b) not guaranteed to take immediate effect...
5
3522
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 only one worker thread running at any time (if a new worker thread start has been requested, any running worker thread results will be invalid). I'm...
14
6850
by: joey.powell | last post by:
I am using VS2005 for a windows forms application. I need to be able to use a worker thread function to offload some processing from the UI thread. The worker thread will need access to a datagridview on the form. I am using the following code to spawn the worker thread... Thread WorkerThread = new Thread(new ThreadStart(WT_MyFunction));...
6
2275
by: Zytan | last post by:
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...
4
2674
by: Zytan | last post by:
Whenever I press pause, it goes to Application.Run(), because the main thread is sleeping, while the worker thread is going. Zytan
0
7270
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7178
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7397
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
5703
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3252
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3239
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.