mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-12 14:51:41 +01:00
Do not throw from Finializer
This commit is contained in:
parent
05661ae9bb
commit
f237086515
@ -135,8 +135,25 @@ namespace Capnp.Rpc
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!_disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
ConsumedCap?.Release();
|
||||
}
|
||||
else
|
||||
{
|
||||
// When called from the Finalizer, we must not throw.
|
||||
// But when reference counting goes wrong, ConsumedCapability.Release() will throw an InvalidOperationException.
|
||||
// The only option here is to suppress that exception.
|
||||
try
|
||||
{
|
||||
ConsumedCap?.Release();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
_disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,8 @@ namespace Capnp.Rpc
|
||||
{
|
||||
if (++_refCount <= 1)
|
||||
{
|
||||
--_refCount;
|
||||
|
||||
throw new ObjectDisposedException(nameof(ConsumedCapability));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user