Trace.UseGlobalLock 属性

定义

获取或设置一个值,该值指示是否应使用全局锁。Gets or sets a value indicating whether the global lock should be used.

public:
 static property bool UseGlobalLock { bool get(); void set(bool value); };
public static bool UseGlobalLock { get; set; }
member this.UseGlobalLock : bool with get, set
Public Shared Property UseGlobalLock As Boolean

属性值

Boolean

如果要使用全局锁,则为 true;否则为 falsetrue if the global lock is to be used; otherwise, false. 默认值为 trueThe default is true.

注解

如果跟踪侦听器不是线程安全的,无论的值如何,始终使用全局锁 UseGlobalLockThe global lock is always used if the trace listener is not thread safe, regardless of the value of UseGlobalLock. IsThreadSafe属性用于确定侦听器是否是线程安全的。The IsThreadSafe property is used to determine if the listener is thread safe. 仅当的值 UseGlobalLockfalse ,并且的值 IsThreadSafe 为时,才使用全局锁 trueThe global lock is not used only if the value of UseGlobalLock is false and the value of IsThreadSafe is true. 默认行为是使用全局锁。The default behavior is to use the global lock.

若要 UseGlobalLock 为设置 Trace ,还可以编辑与应用程序名称对应的配置文件。To set the UseGlobalLock for Trace, you can also edit the configuration file that corresponds to the name of your application. 配置文件的格式应类似于以下示例:The configuration file should be formatted like the following example:

<configuration>  
  <system.diagnostics>  
    <trace useGlobalLock="false" />  
  </system.diagnostics>  
</configuration>  

适用于