ShutdownAsync() private method

Shuts down this environment.
private ShutdownAsync ( ) : Task
return Task
Exemplo n.º 1
0
        /// <summary>
        /// Decrements the reference count for currently active environment and asynchronously shuts down the gRPC environment if reference count drops to zero.
        /// </summary>
        internal static async Task ReleaseAsync()
        {
            GrpcEnvironment instanceToShutdown = null;

            lock (staticLock)
            {
                GrpcPreconditions.CheckState(refCount > 0);
                refCount--;
                if (refCount == 0)
                {
                    instanceToShutdown = instance;
                    instance           = null;
                }
            }

            if (instanceToShutdown != null)
            {
                await instanceToShutdown.ShutdownAsync().ConfigureAwait(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Decrements the reference count for currently active environment and asynchronously shuts down the gRPC environment if reference count drops to zero.
        /// </summary>
        internal static IObservable <Unit> ReleaseAsync()
        {
            GrpcEnvironment instanceToShutdown = null;

            lock (staticLock)
            {
                GrpcPreconditions.CheckState(refCount > 0);
                refCount--;
                if (refCount == 0)
                {
                    instanceToShutdown = instance;
                    instance           = null;
                }
            }

            if (instanceToShutdown != null)
            {
                return(instanceToShutdown.ShutdownAsync());
            }
            else
            {
                return(Observable.ReturnUnit());
            }
        }