How can I tell if the code is being debugged in the .NET IDE???
I have some code, and I want to do something like:
VB Code:
Dim RandomNumber As New Random
If IsRunningInIDE Or Else RandomNumber.Next(0,11) = 10 Then
'do something
End If
I want some code to execute on a 1 in 10 chance. But when testing on my PC while running in IDE I want it to happen all the time.
yea yea...I know code is compiled and executed from the DLL, but the IDE debugs it.
Is this possible?
Woof
Re: How can I tell if the code is being debugged in the .NET IDE???
Why not use a constant boolean. That way if the compiler is any good your debugger code won't even be executed when you set your boolean to false for a release build :)
Re: How can I tell if the code is being debugged in the .NET IDE???
Yea. Thought of that. But didn't want the "hassle" of changing a varible :D
I am lazy.
Woof
Re: How can I tell if the code is being debugged in the .NET IDE???
Your post reminded me that I had seen a Debugger name space before.
Try
Debugger.IsAttached
:)
Re: How can I tell if the code is being debugged in the .NET IDE???
VB Code:
If System.Diagnostics.Debugger.IsAttached Then
Response.Write("Woof")
End If
Cheers.
Woka