System [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00] 1.0.3300.0 1.0.5000.0 2.0.0.0 4.0.0.0 Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details. System.Diagnostics.Switch System.Diagnostics.SwitchLevel(typeof(System.Diagnostics.TraceLevel))

You can use a trace switch to filter out messages based on their importance. The class provides the , , , and properties to test the level of the switch. The property gets or sets the switch's .

You can set the level of a through the application configuration file and then use the configured level in your application. Alternately, you can create a in your code and set the level directly to instrument a specific section of code.

To configure a , edit the configuration file for your application. In this file, you can add or remove a switch, set a switch's value, or clear all the switches previously set by the application. The configuration file should be formatted like the following example:

`<configuration> <system.diagnostics> <switches> <add name="mySwitch" value="1" /> </switches> </system.diagnostics> </configuration>`

This configuration section defines a with the set to mySwitch, and the set to 1, which corresponds to the enumeration value .

In the .NET Framework version 2.0, you can use text to specify the value for a switch. For example, true for a or the text representing an enumeration value, such as Error for a . The line <add name="mySwitch" value="Error" /> is equivalent to <add name="mySwitch" value="1" />.

In your application, you can use the configured switch level by creating a with the same name, as shown in the following example:

code reference: Classic TraceSwitch.TraceError Example#3

By default, the switch property is set using the value specified in the configuration file. If the constructor cannot find initial switch settings in the configuration file, the of the new switch defaults to .

You must enable tracing or debugging to use a switch. The following syntax is compiler specific. If you use compilers other than C# or Visual Basic, refer to the documentation for your compiler.

To enable debugging in C#, add the /d:DEBUG flag to the compiler command line when you compile your code, or add #define DEBUG to the top of your file. In Visual Basic, add the /d:DEBUG=True flag to the compiler command line.

To enable tracing in C#, add the /d:TRACE flag to the compiler command line when you compile your code, or add #define TRACE to the top of your file. In Visual Basic, add the /d:TRACE=True flag to the compiler command line.

These debug and trace compiler switches are not required when using the class in isolation. They are only required in conjunction with or methods that are conditionally compiled.

For more information on instrumenting your application, see and . For more information about configuring and using trace switches, see Trace Switches.

To improve performance, you can make members static in your class.

Provides a multilevel switch to control tracing and debug output without recompiling your code.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  To set the level of your , edit the configuration file that corresponds to the name of your application. In this file, you can add a switch and set its value, remove a switch, or clear all the switches previously set by the application. The configuration file should be formatted like the following example:

  <configuration> <system.diagnostics> <switches> <add name="mySwitch" value="1" /> </switches> </system.diagnostics> </configuration>

  In the .NET Framework version 2.0, you can use text to specify the value for a switch. For example, true for a or the text representing an enumeration value, such as Error for a . The line <add name="mySwitch" value="Error" /> is equivalent to <add name="mySwitch" value="1" />.

  In your application, you can use the configured switch level by creating a with the same name, as shown in the following example:

  code reference: Classic TraceSwitch.TraceError Example#3

  When the constructor cannot find initial switch settings in the configuration file, the property of the new switch is set to .

  The class provides the , , , and properties to test the of the switch. The property gets or sets the switch's .

  To improve performance, you can make members static in your class.

  Initializes a new instance of the class, using the specified display name and description.

  The name to display on a user interface.
  The description of the switch.
- Constructor
  2.0.0.0
  4.0.0.0

  The parameter is used to set the value of the property, the parameter is use to set the value of the property, and the parameter is saved as a field and used to initialize the property on first reference. See the constructor for more information and a code example.

  Initializes a new instance of the class, using the specified display name, description, and default value for the switch.

  The name to display on a user interface.
  The description of the switch.
  The default value of the switch.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Diagnostics.TraceLevel To be added: an object of type 'TraceLevel'

  To set the level of your , edit the configuration file that corresponds to the name of your application. In this file, you can add a switch and set its value, remove a switch, or clear all the switches previously set by the application. The configuration file should be formatted like the following example:

  `<configuration> <system.diagnostics> <switches> <add name="mySwitch" value="0" /> <add name="myNewSwitch" value="3" /> <remove name="mySwitch" /> <clear/> </switches> </system.diagnostics> </configuration>`

  In the .NET Framework version 2.0, you can use text to specify the value for a switch. For example, true for a or the text representing an enumeration value, such as Error for a . The line <add name="mySwitch" value="Error" /> is equivalent to <add name="mySwitch" value="1" />.

  When the constructor cannot find initial switch settings in the configuration file, the property of the new switch is set to .

  Setting this property updates the , , , and properties to reflect the new value.

  Gets or sets the trace level that determines the messages the switch allows.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void

  The method is used by the .NET framework to validate and correct the value of a switch initialized via a configuration file. A message is written to all trace listeners if the switch value specified in the configuration file is not defined by the enumeration and the switch is set to a defined value.

  If you attempt in your code to set the property to a value that is not defined by the enumeration, an exception is thrown.

  Updates and corrects the level for this switch.

- Method
  2.0.0.0
  4.0.0.0
  System.Void

  This method is called internally when the property of the switch changes. The method ensures that the properties relating to the switch's value reflect the new value.

  Sets the property to the integer equivalent of the property.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean To be added: an object of type 'bool'

  You can use the , , , and properties in conjunction with the and classes to emit all messages with a specified importance or greater. When the property is set to the highest importance, , , only error-handling messages are emitted.

  Gets a value indicating whether the switch allows error-handling messages.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean To be added: an object of type 'bool'

  You can use the , , , and properties in conjunction with the and classes to emit all messages with a specified importance or greater. When the property is set to , informational messages, warnings, and error-handling messages are emitted.

  Gets a value indicating whether the switch allows informational messages.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean To be added: an object of type 'bool'

  You can use the , , , and properties in conjunction with the and classes to emit all messages with a specified importance or greater. When the property is set to , all debugging and tracing messages are transmitted.

  Gets a value indicating whether the switch allows all messages.

- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Boolean To be added: an object of type 'bool'

  You can use the , , , and properties in conjunction with the and classes to emit all messages with a specified importance or greater. When the property is set to , warnings and error-handling messages are emitted.

  Gets a value indicating whether the switch allows warning messages.