System.Threading.ManualResetEventSlim.Dispose C# (CSharp) Method

Dispose() protected method

protected Dispose ( bool disposing ) : void
disposing bool
return void
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed.TryRelaxedSet ())
                return;

            if (handle != null) {
                var tmpHandle = AotInterlocked.Exchange (ref handle, null);
                if (used > 0) {
                    // A tiny wait (just a few cycles normally) before releasing
                    SpinWait wait = new SpinWait ();
                    while (used > 0)
                        wait.SpinOnce ();
                }
                // Spicy Pixel: Must use the public interface (e.g. Close)
                tmpHandle.Close ();
                // tmpHandle.Dispose ();
            }
        }

Same methods

ManualResetEventSlim::Dispose ( ) : void

Usage Example

Example #1
0
        public Evaluator(string jsShellPath, string options)
        {
            var psi = new ProcessStartInfo(
                jsShellPath, options
            ) {
                RedirectStandardInput = true,
                RedirectStandardOutput = true,
                RedirectStandardError = true,
                CreateNoWindow = true,
                UseShellExecute = false,
                WindowStyle = ProcessWindowStyle.Hidden
            };

            ManualResetEventSlim stdoutSignal, stderrSignal;
            stdoutSignal = new ManualResetEventSlim(false);
            stderrSignal = new ManualResetEventSlim(false);

            Process = Process.Start(psi);

            ThreadPool.QueueUserWorkItem((_) => {
                _StdOut = Process.StandardOutput.ReadToEnd();
                stdoutSignal.Set();
            });
            ThreadPool.QueueUserWorkItem((_) => {
                _StdErr = Process.StandardError.ReadToEnd();
                stderrSignal.Set();
            });

            _JoinImpl = () => {
                stdoutSignal.Wait();
                stderrSignal.Wait();
                stderrSignal.Dispose();
                stderrSignal.Dispose();
            };
        }
All Usage Examples Of System.Threading.ManualResetEventSlim::Dispose