DefaultTraceListener.AssertUiEnabled 속성

정의

애플리케이션이 사용자 인터페이스 모드에서 실행되고 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

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

속성 값

사용자 인터페이스 모드가 활성화되어 있으면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제에서는 함수가 예외를 throw하는 경우 메서드를 Fail(String, String) 호출하여 오류 메시지를 기록하는 함수를 호출합니다. 속성false이 인 AssertUiEnabled 경우 메서드는 콘솔에도 오류 메시지를 씁니다.

// 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

적용 대상