释放由该对象占用的资源。Releases the resources that are held by the object.
public: virtual void Dispose();
public void Dispose ();
abstract member Dispose : unit -> unit override this.Dispose : unit -> unit
Public Sub Dispose ()
如果通过在 TransactionScope 中设置 Current 来更改环境事务，则在调用 Dispose 时会引发 InvalidOperationException，并还原以前的环境事务值。If you change the ambient transaction by setting Current inside a TransactionScope an InvalidOperationException is thrown when Dispose is called, and the previous ambient transaction value is restored.