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
@ -136,7 +136,24 @@ namespace Capnp.Rpc
|
|||||||
{
|
{
|
||||||
if (!_disposedValue)
|
if (!_disposedValue)
|
||||||
{
|
{
|
||||||
ConsumedCap?.Release();
|
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;
|
_disposedValue = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,8 @@ namespace Capnp.Rpc
|
|||||||
{
|
{
|
||||||
if (++_refCount <= 1)
|
if (++_refCount <= 1)
|
||||||
{
|
{
|
||||||
|
--_refCount;
|
||||||
|
|
||||||
throw new ObjectDisposedException(nameof(ConsumedCapability));
|
throw new ObjectDisposedException(nameof(ConsumedCapability));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user