-1
私はこのような子クラスを持っている:子クラスにDisposeメソッドを構築する方法は?
iはSyncTelemetryChannel Disposeメソッドに何を置くべき?現在、私は、この持っている:
public void Dispose() {}
おかげで、ピーター
私はこのような子クラスを持っている:子クラスにDisposeメソッドを構築する方法は?
iはSyncTelemetryChannel Disposeメソッドに何を置くべき?現在、私は、この持っている:
public void Dispose() {}
おかげで、ピーター
public class SyncTelemetryChannel : ITelemetryChannel
{
private bool _disposed = false;
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool disposing)
{
if (_disposed)
return;
if (disposing)
{
// Free any other managed objects here.
}
// Free any unmanaged objects here.
_disposed = true;
}
}
Thanks LP13とEric。私は思っていた、あなたのコメントは私を助けた。 – user1224643
'ITelemetryChannel'はインターフェースがありますか? (ダブルチェック) –
disposeパターンを正しく実装する必要があります。あなたのオブジェクトはアンマネージドリソースの所有権を握っていますか? –