473,769 Members | 3,872 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Debugging thread problem

Hi there,

Has anyone had any problems debugging a thread in VS 2005. If I put a
breakpoint on a worker thread (the only one in the app) and then run the app
two things happen:

1) It takes an unusually long time for the breakpoint to kick in once
encountered
2) When it finally does break, I can't step through any code. As soon as I
try, the debugger just runs off somewhere and never returns control to me.

Any suggestions? Thanks..
Sep 14 '06 #1
9 6156
Update:

Unless there's some way to corrupt memory in C#/.NET (I'm relatively new to
it but very experienced in C/C++), this appears to be a VS bug though any
feedback would still be appreciated. That is, if I situate my breakpoint
earlier in the code I can debug no problem. If I then move the breakpoint
ahead one line at time, I eventually reach a point where the problem
suddenly surfaces. This occurs when I move the breakpoint to the first line
of a function outside the file where the thread actually starts. As soon as
I try to step into that function, the debugger takes about 20 seconds to do
so and when it finally does break, I can no longer step at all since the
debugger never returns. At one point I did notice a very brief message flash
on the bottom of the screen (in a small yellow window) to the effect that VS
was waiting for some internal operation to finish or something like that (it
flashed too quicly too digest it all). Anyway, this is a serious problem if
I can't debug my thread so any input would be welcome. Thanks.
Sep 14 '06 #2

"John Brown" <no_spam@_nospa m.comwrote in message
news:Od******** ******@TK2MSFTN GP03.phx.gbl...
| Hi there,
|
| Has anyone had any problems debugging a thread in VS 2005. If I put a
| breakpoint on a worker thread (the only one in the app) and then run the
app
| two things happen:
|
| 1) It takes an unusually long time for the breakpoint to kick in once
| encountered
| 2) When it finally does break, I can't step through any code. As soon as I
| try, the debugger just runs off somewhere and never returns control to me.
|
| Any suggestions? Thanks..
|
|

What kind of application is this? Windows forms or console like.
If Windows forms, do you pass the form object to the other thread?

Willy.
Sep 14 '06 #3
What kind of application is this? Windows forms or console like.
If Windows forms, do you pass the form object to the other thread?
Well, the worker thread's main function (entry point) is a member of a
"Form" derivative and it passes a reference to the enclosing object (form)
to a function in another file and that's exactly where things start failing
(as soon as the latter function is called). However, note that all GUI
processing is being routed back to the main GUI thread via
"Control.Invoke ()". In any case, is there a reason it should fail as soon
that function is called (perhaps you're alluding to some marshalling issue I
haven't considered - does the form's reference need to be marshalled to the
thread in some way). Thanks for your assistance (appreciated).
Sep 14 '06 #4

I've noticed this problem when stepping from code we have source for
to code we don't have source for (a 3rd party dll) when the other code
was compiled width debugging enabled. I most often run into this when
debugging unit tests and I step past the end of one test and control
returns to the test framework.

Does the problem occur always on a particular line of code? What
happens if instead of stepping into this line you step over it? Can
you set a breakpoint later in the program and it works ok (past the
offending line)?

Sam

------------------------------------------------------------
We're hiring! B-Line Medical is seeking Mid/Sr. .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.


On Thu, 14 Sep 2006 18:07:36 -0400, "John Brown" <no_spam@_nospa m.com>
wrote:
>Update:

Unless there's some way to corrupt memory in C#/.NET (I'm relatively new to
it but very experienced in C/C++), this appears to be a VS bug though any
feedback would still be appreciated. That is, if I situate my breakpoint
earlier in the code I can debug no problem. If I then move the breakpoint
ahead one line at time, I eventually reach a point where the problem
suddenly surfaces. This occurs when I move the breakpoint to the first line
of a function outside the file where the thread actually starts. As soon as
I try to step into that function, the debugger takes about 20 seconds to do
so and when it finally does break, I can no longer step at all since the
debugger never returns. At one point I did notice a very brief message flash
on the bottom of the screen (in a small yellow window) to the effect that VS
was waiting for some internal operation to finish or something like that (it
flashed too quicly too digest it all). Anyway, this is a serious problem if
I can't debug my thread so any input would be welcome. Thanks.
Sep 14 '06 #5
I've noticed this problem when stepping from code we have source for
to code we don't have source for (a 3rd party dll) when the other code
was compiled width debugging enabled. I most often run into this when
debugging unit tests and I step past the end of one test and control
returns to the test framework.

Does the problem occur always on a particular line of code? What
happens if instead of stepping into this line you step over it? Can
you set a breakpoint later in the program and it works ok (past the
offending line)?
I can step all over the function in file 1 anyway I like but as soon as I
call a function in file 2 the problem starts (I own all source). Willy may
be on to something however since I just discovered that the problem stops
when I pass "null" to the offending function in file 2 instead of the "Form"
reference I normally pass. I think there may be some marshalling issue here
perhaps (with the form's reference). The situation is quite simple however.
A form starts the worker thread going in its "OnLoad()" handler by invoking
"BackgroundWork er.RunWorkerAsy nc()" (standard 2.0 class). The worker thread
(another function in the form's class) then passes "this" to a function in
another file. That's when all the trouble starts. The debugger goes away for
a 20 second smoke (or whatever it's doing) and then it finally breaks at the
first line in the latter function. At this point however I can't step any
further without the debugger going into la la land permanently. Passing
"null" instead of "this" however eliminates the problem. I thought that
perhaps instead of passing "this", maybe I need to marshal the form's
pointer to the thread somehow but if so then it's news to me (I'm relatively
new to C# and .NET though very experienced in C/C++). Any thoughts?
Sep 15 '06 #6
>What kind of application is this? Windows forms or console like.
>If Windows forms, do you pass the form object to the other thread?

Well, the worker thread's main function (entry point) is a member of a
"Form" derivative and it passes a reference to the enclosing object (form)
to a function in another file and that's exactly where things start
failing (as soon as the latter function is called). However, note that all
GUI processing is being routed back to the main GUI thread via
"Control.Invoke ()". In any case, is there a reason it should fail as soon
that function is called (perhaps you're alluding to some marshalling issue
I haven't considered - does the form's reference need to be marshalled to
the thread in some way). Thanks for your assistance (appreciated).
By sheer coincidence I came across the following link while pursuing another
matter related to this problem (what luck!). I'm still tinkering but the
"DebuggerDispla y" attribute seems to have solved the problem for the moment.
See the "System.Windows .Forms.Form and multithreading" section here:

http://blogs.msdn.com/greggm/archive...18/494648.aspx
Sep 15 '06 #7
John,

Although in VB.Net do I have the same problem. I hope that this is one of
the fixes done in the next service pack, because this makes multithreading
not fine to use at the moment in my idea. My screen is completely blanked
out in those cases.

(The Microsoft development debugger team is AFAIK the same for C# and
VB.Net).

Cor

"John Brown" <no_spam@_nospa m.comschreef in bericht
news:Od******** ******@TK2MSFTN GP03.phx.gbl...
Hi there,

Has anyone had any problems debugging a thread in VS 2005. If I put a
breakpoint on a worker thread (the only one in the app) and then run the
app two things happen:

1) It takes an unusually long time for the breakpoint to kick in once
encountered
2) When it finally does break, I can't step through any code. As soon as I
try, the debugger just runs off somewhere and never returns control to me.

Any suggestions? Thanks..

Sep 15 '06 #8

"John Brown" <no_spam@_nospa m.comwrote in message
news:ua******** ******@TK2MSFTN GP06.phx.gbl...
| >What kind of application is this? Windows forms or console like.
| >If Windows forms, do you pass the form object to the other thread?
| >
| Well, the worker thread's main function (entry point) is a member of a
| "Form" derivative and it passes a reference to the enclosing object
(form)
| to a function in another file and that's exactly where things start
| failing (as soon as the latter function is called). However, note that
all
| GUI processing is being routed back to the main GUI thread via
| "Control.Invoke ()". In any case, is there a reason it should fail as
soon
| that function is called (perhaps you're alluding to some marshalling
issue
| I haven't considered - does the form's reference need to be marshalled
to
| the thread in some way). Thanks for your assistance (appreciated).
|
| By sheer coincidence I came across the following link while pursuing
another
| matter related to this problem (what luck!). I'm still tinkering but the
| "DebuggerDispla y" attribute seems to have solved the problem for the
moment.
| See the "System.Windows .Forms.Form and multithreading" section here:
|
| http://blogs.msdn.com/greggm/archive...18/494648.aspx
|
|

Righht John, that's exactly what you are after, I hope one of the
work-arounds will help you out.

Willy.
Sep 15 '06 #9
Righht John, that's exactly what you are after, I hope one of the
work-arounds will help you out.
So far so good. Thanks for your help. Hopefully MSFT will get around to
repairing this situation as I'm sure many others have endured the same
frustration.
Sep 15 '06 #10

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

Similar topics

1
2983
by: Elbert Lev | last post by:
I started with Python two weeks ago and already saved some time and efforts while writing 2 programs: 1. database extraction and backup tool, which runs once a month and creates a snapshot of important data, compresses and saves it. 2. pop3 "watchdog", which reads e-mail from a pop3 mailbox and in the case there is no mail sends e-mail messages to technicians. (the presence of e-mail in the mailbox tells that the system I'm monitoring...
3
2805
by: Rhino | last post by:
I've spent the last couple of hours trying to figure out how to debug a Java stored procedure and am just going in circles. The last straw came when I got "Cannot open input stream for default" when I launched the IBM Distributed Debugger via D:\IBMDebug>idebug.exe -qdaemon -quiport=8000,8001 First, a bit of background. I am running DB2 V7.2 with Fixpack 9 applied on Windows XP Professional (all critical service applied). I've written...
4
1331
by: Bruno van Dooren | last post by:
Hi, i was debugging a multithreaded app, when i stumbled across some weird behavior of the debugger. in the destructor of my main object i send a stop event to the worker thread, and then wait until that thread has finished. m_Stop = true; while(GetExitCodeThread() == STILL_RUNNING)
3
3643
by: R Millman | last post by:
under ASP.NET, single stepping in debug mode appears not to stop within event procedures. i.e. 1) Create web page with submit button and event procedure for the click event in the code behind page, 2) Breakpoint in the Page_Load, 3) debug the web page and click the submit button, 4) "step into" under debug several times, 5) The debugger does not stop at any of the statements in the click event handler. A breakpoint is needed in each...
16
4221
by: Serdar Kalaycý | last post by:
Hi everybody, My problem seems a bit clichè but I could not work around. Well I read lots of MSDN papers and discussions, but my problem is a bit different from them. When I tried to run the project in debug mode (by hitting F5) it gives an error message "Error while trying to run project: Unable to start debugging on the web server.
4
1552
by: Nadav Popplewell | last post by:
Hi Everybody, I've got a problem debugging ASP.NET applications on an XP SP2 System. The Details: Up to now I've been developing on an XP SP1 computer. Several days ago I got a new computer with XP SP2 installed. I moved the ASP.NET to the new computer (got the source from source safe and compiled on that computer), and i've run into several problems which are probably related.
1
2050
by: DEWright_CA | last post by:
I have built a pretty basic site and now when I try t debug it I get a error that says; {0}: Build (web): "The type initializer for 'System.Web.Compilation.CompilationLock' threw an exceptoin. I am using the final VS2005Pro, running on WinXP MCE 2005 on a Laptop. Any Suggestions?
5
3645
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As New System.Diagnostics.Process 'p.Start(MDEPDirStr & "macrun.exe", sPPTOut) p.Start("C:\WINDOWS\SYSTEM32\CALC.EXE") 'p.Start("C:\WINDOWS\SYSTEM32\macrun.exe", sPPTOut)
10
1976
by: Doug Robertson | last post by:
First off, I'm a hardware/OS guy. I just write code on the side and I'm completely self taught - so bear in mind my total lack of expertise. I have a program originally written in VB2003 using the dotnet 1.1 framework. The program makes extensive use of Win32 API calls to help manage and track remote access sessions with out clients. I've left it running for days at a time on my system with no problems. It has always been stable. I...
0
10206
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
10035
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8863
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...
1
7403
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5293
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
5441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3949
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

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.