ThreadLocal<T>.Value 屬性

定義

取得或設定目前執行緒的這個執行個體的值。Gets or sets the value of this instance for the current thread.

public:
 property T Value { T get(); void set(T value); };
public T Value { get; set; }
member this.Value : 'T with get, set
Public Property Value As T

屬性值

T

傳回這個 ThreadLocal 負責初始化之物件的執行個體。Returns an instance of the object that this ThreadLocal is responsible for initializing.

例外狀況

ThreadLocal<T> 執行個體已經過處置。The ThreadLocal<T> instance has been disposed.

初始化函式會嘗試遞迴參考 ValueThe initialization function attempted to reference Value recursively.

沒有提供任何無參數的建構函式,也沒有提供任何値 Factory。No parameterless constructor is provided and no value factory is supplied.

備註

如果先前未針對目前的執行緒初始化這個實例,則存取 Value 將會嘗試將它初始化。If this instance was not previously initialized for the current thread, accessing Value will attempt to initialize it. 如果在結構化期間提供初始化函數,則會叫用函式來抓取 Value的初始值,以進行初始化。If an initialization function was supplied during the construction, that initialization will happen by invoking the function to retrieve the initial value for Value. 否則,將會使用 T 的預設值。Otherwise, the default value of T will be used.

適用於

另請參閱