コード例 #1
0
        public void Dispose()
        {
            if (CanSignal && !_hasExited)
            {
                // Request asynchronous termination because SengSignal allocates additional resources and may fail.
                // (Dispose should not fail!)
                _helper.RequestAsyncTermination(_token);
            }

            ChildProcessStateCollection.RemoveChildProcessState(this);
            _exitedEvent.Dispose();
        }
コード例 #2
0
        /// <summary>
        /// Obtains the <see cref="UnixChildProcessState"/> associated with the specified process token.
        /// </summary>
        /// <param name="token">The process token.</param>
        /// <param name="holder">
        /// When this method returns, contains a <see cref="UnixChildProcessStateHolder"/> that wraps the <see cref="UnixChildProcessState"/>
        /// associated with the specified process token, if the process token is found; otherwise, unspecified.
        /// </param>
        /// <returns><see langword="true"/> if the process token is found; otherwise, <see langword="false"/>.</returns>
        public static bool TryGetChildProcessState(long token, [NotNullWhen(true)] out UnixChildProcessStateHolder?holder)
        {
            if (!ChildProcessStateCollection.TryGetChildProcessState(token, out var state))
            {
                holder = null;
                return(false);
            }

            if (!state.TryAddRef())
            {
                // Disposal has already started.
                holder = null;
                return(false);
            }

            holder = new UnixChildProcessStateHolder(state);
            return(true);
        }
コード例 #3
0
        /// <summary>
        /// Creates a <see cref="UnixChildProcessState"/> with a new process token (an identifier unique within the current AssemblyLoadContext).
        /// </summary>
        /// <returns>A <see cref="UnixChildProcessStateHolder"/> that wraps the created <see cref="UnixChildProcessState"/>.</returns>
        public static UnixChildProcessStateHolder Create()
        {
            var state = ChildProcessStateCollection.Create();

            return(new UnixChildProcessStateHolder(state));
        }
コード例 #4
0
 public void Dispose()
 {
     ChildProcessStateCollection.RemoveChildProcessState(this);
     _exitedEvent.Dispose();
 }
コード例 #5
0
        /// <summary>
        /// Creates a <see cref="UnixChildProcessState"/> with a new process token (an identifier unique within the current AssemblyLoadContext).
        /// </summary>
        /// <returns>A <see cref="UnixChildProcessStateHolder"/> that wraps the created <see cref="UnixChildProcessState"/>.</returns>
        public static UnixChildProcessStateHolder Create(UnixChildProcessStateHelper helper, bool allowSignal)
        {
            var state = ChildProcessStateCollection.Create(helper, allowSignal);

            return(new UnixChildProcessStateHolder(state));
        }