Check whether the application is currently being debugged

 

If you want to know whether the application is currently being debugged you can use the following code;

Public Shared ReadOnly Property DebugMode() As Boolean
    Get
        Dim rtn As Boolean = False

#If DEBUG Then
         rtn = True
#End If
        Return rtn
    End Get
End Property

The part of code in the if statement will only be executed if the application is currently being debugged, therefore the return value will be left as false.