473,811 Members | 2,665 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 1960
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**********@g mail.comwrote in message
news:11******** **************@ r35g2000prh.goo glegroups.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**********@g mail.comwrote in message
news:11******** *************@c 18g2000prb.goog legroups.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

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

Similar topics

2
1404
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 position and get to the second one by trace step by step. In fact, the lines below that has the same...
1
3616
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 returns -- I have to do a "break all" inside the debugger, then find this thread and examine its call...
7
2133
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 routine, which calls Me.Invoke, the invoke call blocks forever. But I can't figure out why the main...
7
2699
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
5996
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 anyway. I would rather have some way of allowing the main thread to tell the worker thread that it...
5
3552
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 using the below method to invoke a new worker thread, but when stress testing this I'm sometimes...
14
6892
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)); WorkerThread.IsBackground = true; WorkerThread.Start(); The problem I am having is...I cannot seem...
6
2289
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 it is a worker thread that is deadlocked.
4
2685
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
9607
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10652
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10137
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9211
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5561
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5700
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4346
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
2
3874
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3026
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.