Bagikan melalui


DefaultTraceListener.AssertUiEnabled Properti

Definisi

Mendapatkan atau menetapkan nilai yang menunjukkan apakah aplikasi berjalan dalam mode antarmuka pengguna.

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

Nilai Properti

true jika mode antarmuka pengguna diaktifkan; jika tidak, false.

Contoh

Contoh kode berikut memanggil fungsi yang memanggil Fail(String, String) metode untuk mencatat pesan kesalahan jika fungsi melemparkan pengecualian. AssertUiEnabled Jika properti adalah false, metode ini juga menulis pesan kesalahan ke konsol.

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

Berlaku untuk