By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,028 Members | 1,869 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,028 IT Pros & Developers. It's quick & easy.

Debugging hanging C# program

P: n/a
I have a multi-threaded C# program that hangs for 5-10 seconds
intermittently. Are there any built in tools in Visual Studio .NET to
somehow instrument my code to see where my performance problems are. It is
rough debugging it using breakpoints due to the multi-threading.
Jul 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
zfield,

You can use the CLR profiler to get an idea of how your code is running.
You can find it at the Tools and Utilities page at the .NET Developer Center
on MSDN at (watch for line wrap):

http://msdn.microsoft.com/netframewo...s/default.aspx

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"zfeld" <zf******@hotmail.com> wrote in message
news:eR**************@TK2MSFTNGP15.phx.gbl...
I have a multi-threaded C# program that hangs for 5-10 seconds
intermittently. Are there any built in tools in Visual Studio .NET to
somehow instrument my code to see where my performance problems are. It is
rough debugging it using breakpoints due to the multi-threading.

Jul 21 '05 #2

P: n/a
To start with I'd give your threads a meaningful name (if at all possible),
then write some sort of debug logger that writes text to disk. From here you
can litter your code with "trace" statements that get logged to a text file.
If you add a time stamp to each entry, you then can trace, from one point in
a thread (using your thread name) to another.

Be sure to make your logging mechanism thread safe.

Here's an example...

#if DEBUG
readonly object grabInterfaceLock = new object();
#endif

public void WriteLog ( string log )
{

#if DEBUG
lock ( grabInterfaceLock )
{
try
{
// filename is...
string filename = @"C:\debuglog.txt";

// prepend the date
log = DateTime.Now.ToString() + " - " + log;

// open up the file and append data
StreamWriter logwriter = File.AppendText(filename);
logwriter.WriteLine( log );
logwriter.Close();
}
catch ( Exception )
{
}
}
#endif

}

"zfeld" <zf******@hotmail.com> wrote in message
news:eR**************@TK2MSFTNGP15.phx.gbl...
I have a multi-threaded C# program that hangs for 5-10 seconds
intermittently. Are there any built in tools in Visual Studio .NET to
somehow instrument my code to see where my performance problems are. It is
rough debugging it using breakpoints due to the multi-threading.

Jul 21 '05 #3

P: n/a
Hi,
take a look at http://www.automatedqa.com/products/aqtime/index.asp I tested
it a time ago and it was very good, unfortunally my company did not purchase
it.

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"zfeld" <zf******@hotmail.com> wrote in message
news:eR**************@TK2MSFTNGP15.phx.gbl...
I have a multi-threaded C# program that hangs for 5-10 seconds
intermittently. Are there any built in tools in Visual Studio .NET to
somehow instrument my code to see where my performance problems are. It is
rough debugging it using breakpoints due to the multi-threading.

Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.