Freezable.WritePreamble 方法


验证 Freezable 是否未被冻结,并且是否正在从有效的线程上下文中访问它。Verifies that the Freezable is not frozen and that it is being accessed from a valid threading context. Freezable 的继承项应当在任何 API 一开始写入不属于依赖项属性的数据成员时调用此方法。Freezable inheritors should call this method at the beginning of any API that writes to data members that are not dependency properties.

 void WritePreamble();
protected void WritePreamble ();
member this.WritePreamble : unit -> unit
Protected Sub WritePreamble ()


Freezable 实例已冻结,并且无法写入其成员。The Freezable instance is frozen and cannot have its members written to.


此方法调用 VerifyAccess 来验证线程上下文是否可访问,如果 Freezable 实例已冻结,则会引发异常。This method calls VerifyAccess to verify the threading context is accessible, and it throws an exception if the Freezable instance is already frozen.


派生自 Freezable 的类应调用 WritePreamble(),然后才能尝试写入不是依赖项属性的任何成员。Classes that derive from Freezable should call WritePreamble() before attempting to write to any members that are not dependency properties. 如果在 API 中调用 WritePreamble(),则可以省略对 ReadPreamble()的调用。If you call WritePreamble() in an API, you can omit a call to ReadPreamble().