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, String)

Writes a message 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 message As String _
)
[C#]
public static void WriteLineIf(
   bool condition,
   string message
);
[C++]
public: static void WriteLineIf(
   bool condition,
   String* message
);
[JScript]
public static function WriteLineIf(
   condition : Boolean,
   message : String
);

Parameters

condition
A condition which if true will cause the message to be written.
message
A message 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.

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