DefaultTraceListener.AssertUiEnabled Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a value indicating whether the application is running in user-interface mode.
public:
property bool AssertUiEnabled { bool get(); void set(bool value); };
public bool AssertUiEnabled { get; set; }
member this.AssertUiEnabled : bool with get, set
Public Property AssertUiEnabled As Boolean
Property Value
true
if user-interface mode is enabled; otherwise, false
.
Examples
The following code example calls a function that calls the Fail(String, String) method to log an error message if the function throws an exception. If the AssertUiEnabled property is false
, the method also writes the error message to the console.
// Compute the next binomial coefficient and handle all exceptions.
try
{
result = CalcBinomial(possibilities, iter);
}
catch(Exception ex)
{
string failMessage = String.Format("An exception was raised when " +
"calculating Binomial( {0}, {1} ).", possibilities, iter);
defaultListener.Fail(failMessage, ex.Message);
if (!defaultListener.AssertUiEnabled)
{
Console.WriteLine(failMessage+ "\n" +ex.Message);
}
return;
}
' Compute the next binomial coefficient and handle all exceptions.
Try
result = CalcBinomial(possibilities, iter)
Catch ex As Exception
Dim failMessage As String = String.Format( _
"An exception was raised when " & _
"calculating Binomial( {0}, {1} ).", _
possibilities, iter)
defaultListener.Fail(failmessage, ex.Message)
If Not defaultListener.AssertUiEnabled Then
Console.WriteLine(failMessage & vbCrLf & ex.Message)
End If
Return
End Try
Applies to
שתף איתנו פעולה ב- GitHub
ניתן למצוא את המקור לתוכן זה ב- GitHub, שם ניתן גם ליצור ולסקור בעיות ולמשוך בקשות. לקבלת מידע נוסף, עיין במדריך התורמים שלנו.