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

Debugging problems with multiple threads in VS 2005

I'm using Visual Studio 2005 Pro final, and I've noticed some bizarre
behaviour when I'm debugging programs with multiple threads.
Specifically, if I set a breakpoint in one of my non-UI threads, and
try to step-over a line of code, my thread aborts and pretty much
breaks my application. I tried a similar test in a console application
and it seems to work fine.

Here is a sample to show what I mean. Create a new Windows application
called WindowsApplication1, and replace form1.cs with this code:

=== begin source code ===

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.IO;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Thread newThread = new Thread(new ThreadStart(_runThread));
newThread.Start();
}

private void _runThread()
{
File.AppendAllText(".\\tempfile.txt", "this is a line of text\n");
}
}
}

=== end source code ===

put a breakpoint in _runThread, and run the application. What it is
SUPPOSED to do, is display the app and just put that line of text into
a text file (run the app normally, and you see that it does). But if
you debug with a breakpoint in _runThread, what happens is that when it
hits the breakpoint, it pauses for a LONG time in the debugger (10-15
seconds) and then brings you to that breakpoint... but if you try to
"step over", it just kicks out of the thread with an error message in
the output of "A first chance exception of type
'System.Threading.ThreadAbortException' occurred in
System.Windows.Forms.dll" in the output window and the thread is gone.

Does anyone have any idea why this is happening? Is it something I'm
doing wrong in my code? It doesn't matter WHAT I am trying to do in
the _runThread method, ANY code which I attempt to debug will give me
that ThreadAbortException if I try to debug. But it runs just fine if
I run it without any breakpoints. And I can debug on the UI thread
without any problems at all.

Nov 22 '05 #1
1 2838
Doy. if you make _runThread a static method, it works just fine.

Nov 25 '05 #2

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

Similar topics

5
by: Noa Garnett | last post by:
I'm developing on C++, using visual studio 6.0 with service pack 5. I have a memory corruption while debugging. Some of the variables I'm using are suddenly set to zero while progressing along the...
16
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...
5
by: Bruce Schechter | last post by:
I just started to develop an ASP.NET application in vs.net 2003 . But each time I try to execute the application (which is basically empty so far), I get a dialog box titled "Microsoft Development...
1
by: Jason Smith | last post by:
I'm rather new with vb.net and I'm having problems debugging a large vb.net application. The application is randomly crashing at two locations with "referenced memory at 0x0" violations. My...
13
by: Arne Garvander | last post by:
Sometimes I get an exception in the browser and I get prompted to start Visual Studio 2005 for debugging. Sometimes I would like to start client side debugging on demand. How can I do that? --...
6
by: Rob R. Ainscough | last post by:
I can't seem to locate the appropriate area in VS 2005 where I can accomplish this -- is this a C# only option? Thanks, Rob.
10
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...
0
by: Robson Siqueira | last post by:
Guys, I am facing a weird problem. When I am debugging a solution with multiple projects, I always receive the message "the breakpoint will not currently be hit. the source code is different...
0
by: Bob Bryan | last post by:
This is just a note to anyone who is trying to debug multiple threads using Visual Studio .Net 2005 and running into the problem where a breakpoint is hit in the newly created thread, but stepping...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.