MailMessage.Dispose メソッド
定義
MailMessage で使用したリソースを解放します。Releases the resources used by the MailMessage.
オーバーロード
Dispose(Boolean) |
MailMessage によって使用されているアンマネージド リソースを解放し、オプションでマネージド リソースも解放します。Releases the unmanaged resources used by the MailMessage and optionally releases the managed resources. |
Dispose() |
MailMessage によって使用されているすべてのリソースを解放します。Releases all resources used by the MailMessage. |
Dispose(Boolean)
MailMessage によって使用されているアンマネージド リソースを解放し、オプションでマネージド リソースも解放します。Releases the unmanaged resources used by the MailMessage and optionally releases the managed resources.
protected:
virtual void Dispose(bool disposing);
protected virtual void Dispose (bool disposing);
abstract member Dispose : bool -> unit
override this.Dispose : bool -> unit
Protected Overridable Sub Dispose (disposing As Boolean)
パラメーター
- disposing
- Boolean
マネージド リソースとアンマネージド リソースの両方を解放する場合は true
。アンマネージド リソースだけを解放する場合は false
。true
to release both managed and unmanaged resources; false
to release only unmanaged resources.
注釈
このメソッドは、パブリックな Dispose()
メソッドと Finalize メソッドによって呼び出されます。This method is called by the public Dispose()
method and the Finalize method. Dispose()``Dispose(Boolean)
パラメーターをに設定して、保護されたメソッドを呼び出し disposing
true
ます。Dispose()
invokes the protected Dispose(Boolean)
method with the disposing
parameter set to true
. FinalizeDispose
disposing
をに設定してを呼び出し false
ます。Finalize invokes Dispose
with disposing
set to false
.
disposing
パラメーターが true の場合、このメソッドは、このが参照するすべてのマネージオブジェクトによって保持されているすべてのリソースを解放 MailMessage します。When the disposing
parameter is true, this method releases all resources held by any managed objects that this MailMessage references. このメソッドは、参照される各オブジェクトの Dispose()
メソッドを呼び出します。This method invokes the Dispose()
method of each referenced object.
注意 (継承者)
Dispose
は、他のオブジェクトから複数回呼び出すことができます。
Dispose
can be called multiple times by other objects. をオーバーライドする場合は、以前 Dispose(Boolean)
にを呼び出したときに破棄されたオブジェクトを参照しないように注意 Dispose
してください。When overriding Dispose(Boolean)
be careful not to reference objects that have been previously disposed of in an earlier call to Dispose
. を実装する方法の詳細については Dispose(Boolean)
、「 [Dispose メソッドの実装](/dotnet/standard/garbage-collection/implementing-dispose)」を参照してください。For more information about how to implement Dispose(Boolean)
, see [Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose).
およびの詳細については Dispose
Finalize() 、「 アンマネージリソースのクリーンアップ 」と「 Finalize メソッドのオーバーライド」を参照してください。For more information about Dispose
and Finalize(), see Cleaning Up Unmanaged Resources and Overriding the Finalize Method.
適用対象
Dispose()
MailMessage によって使用されているすべてのリソースを解放します。Releases all resources used by the MailMessage.
public:
virtual void Dispose();
public void Dispose ();
abstract member Dispose : unit -> unit
override this.Dispose : unit -> unit
Public Sub Dispose ()
実装
例
次のコード例は、を破棄する方法を示して MailMessage います。The following code example demonstrates disposing a MailMessage.
注釈
Dispose メソッドは、MailMessage の使用が完了したときに呼び出します。Call the Dispose method when you are finished using the MailMessage. Dispose メソッドによって、MailMessage は使用不可の状態になります。The Dispose method leaves the MailMessage in an unusable state. Dispose呼び出し後は、MailMessageによって占有されていたメモリをガベージ コレクターがクリアできるよう、MailMessage へのすべての参照を解放する必要があります。After calling Dispose, you must release all references to the MailMessage so the garbage collector can reclaim the memory that the MailMessage was occupying. 詳細については、アンマネージ リソースのクリーンアップおよびDispose メソッドの実装を参照してください。For more information, see Cleaning Up Unmanaged Resources and Implementing a Dispose Method.
注意
Dispose への最後の参照を解放する前に、必ず MailMessage を呼び出してください。Always call Dispose before you release your last reference to the MailMessage.