ANHAdmin.ProcessCaller.DoWork C# (CSharp) Method

DoWork() protected method

/// Initialises a ProcessCaller without an association to an /// ISynchronizeInvoke. All events raised from this object /// will be delievered via the worker thread. /// Launch a process, but do not return until the process has exited. That way we can kill the process if a cancel is requested.
protected DoWork ( ) : void
return void
        protected override void DoWork()
        {
            StartProcess();

            // Wait for the process to end, or cancel it
            while (!process.HasExited)
            {
                Thread.Sleep(SleepTime); // sleep
                if (CancelRequested)
                {
                    // Not a very nice way to end a process,
                    // but effective.
                    process.Kill();
                    AcknowledgeCancel();
                }
            }
        }