예제 #1
0
        OnLogicalLogClose(LogicalLog ToClose, CancellationToken cancellationToken)
        {
            await _Lock.WaitUntilSetAsync(cancellationToken).ConfigureAwait(false);

            try
            {
                PhysicalLog handleOwner = null;

                ReleaseAssert.AssertIfNot(_Logs.TryGetValue(ToClose.OwnerId, out handleOwner), "_Logs index is inconsistent");

                if (await handleOwner.OnCloseLogicalLog(ToClose, cancellationToken).ConfigureAwait(false))
                {
                    // last handle or logical log closed on the PhysicalLog, removed from this index
                    _Logs.Remove(ToClose.OwnerId);
                    if ((_Handles.Count == 0) && (_Logs.Count == 0))
                    {
                        var m = _AppDomainPhysLogManager;
                        _AppDomainPhysLogManager = null;
                        await m.CloseAsync(cancellationToken).ConfigureAwait(false);
                    }
                }
            }
            finally
            {
                _Lock.Set();
            }
        }