NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Trace.WriteLineIf (Boolean, Object, String)

Writes a category name and the name of the value parameter followed by a line terminator to the trace listeners in the Listeners collection if a condition is true. The default line terminator is a carriage return followed by a line feed ("\r\n").

[Visual Basic]
Overloads Public Shared Sub WriteLineIf( _
   ByVal condition As Boolean, _
   ByVal value As Object, _
   ByVal category As String _
)
[C#]
public static void WriteLineIf(
   bool condition,
   object value,
   string category
);
[C++]
public: static void WriteLineIf(
   bool condition,
   Object* value,
   String* category
);
[JScript]
public static function WriteLineIf(
   condition : Boolean,
   value : Object,
   category : String
);

Parameters

condition
A condition which if true will cause the message to be written.
value
An Object whose name is sent to the Listeners.
category
A category name to write.

Remarks

By default, the output is written to the managed code debuggers, the Microsoft.Win32.Interop.Windows.OutputDebugString API and to the Log method.

The category can be used to group output messages.

Notes to Implementers: You can minimize the performance penalty of instrumenting your application by using If...Then statements instead of using WriteIf statements. The following two code examples send the same debugging message. However, the first example is much faster when tracing is off, because if mySwitch.TraceError evaluates to false you do not call Write. The second example always calls WriteIf, even when mySwitch.TraceError is false and no tracing output is produced. This can result in unnecessary execution of an arbitrarily complex code.

First example.

if(mySwitch.TraceError) 
   Trace.Write("aNumber = " + aNumber + " out of range");

Second example.

Trace.WriteIf(mySwitch.TraceError, "aNumber = " + aNumber + " out of range");

See Also

Trace Class | Trace Members | System.Diagnostics Namespace | Trace.WriteLineIf Overload List | Debug | Trace | BooleanSwitch | TraceSwitch | TraceListener | DefaultTraceListener | ConditionalAttribute | ConditionalAttribute | ConditionalAttribute | ConditionalAttribute | ConditionalAttribute