Exemplo n.º 1
0
        // Show debug dialog
        void OnDebuggerStop(object sender, DebuggerStopEventArgs e)
        {
            var ui = new UI.DebuggerDialog(e);

            // viewer writer?
            var writer = FarUI.Writer as TranscriptOutputWriter;

            // no? if console writer and transcript then use transcript
            if (writer == null && FarUI.Writer is ConsoleOutputWriter && Transcript != null)
            {
                writer = Transcript;
            }

            // add View handler
            if (writer != null)
            {
                ui.OnView = delegate
                {
                    // ensure file
                    if (writer.FileName == null)
                    {
                        writer.Write(string.Empty);
                    }

                    // view file
                    Zoo.StartExternalViewer(writer.FileName);
                };
            }

            e.ResumeAction = ui.Show();
        }
Exemplo n.º 2
0
        internal static void StopJobsOnExit()
        {
            bool force = false;

            while (JobList.Count > 0)
            {
                // try to get a job because the list may get empty after the check for the Count
                Job job;
                try
                {
                    job = JobList[0];
                }
                catch (ArgumentOutOfRangeException)
                {
                    return;
                }

                if (force || !job.IsRunning && job.Length == 0)
                {
                    if (job.IsRunning)
                    {
                        job.StopJob();
                    }
                    job.Dispose();
                    continue;
                }

                string message = string.Format(null, @"
Job:
{0}

State: {1}
Output: {2}

Abort: discard the job
Retry: wait for exit or view output
Ignore: discard all jobs and output

", job.ToLine(100), job.StateText, job.Length);

                Far.Api.UI.WindowTitle = Res.BackgroundJobs;
                switch (Far.Api.Message(message, Res.BackgroundJobs, MessageOptions.Gui | MessageOptions.AbortRetryIgnore))
                {
                case 0:
                    if (job.IsRunning)
                    {
                        job.StopJob();
                    }
                    job.Dispose();
                    break;

                case 1:
                    if (job.IsRunning)
                    {
                        Far.Api.UI.WindowTitle = "Waiting for a background job...";
                        job.Finished.WaitOne();
                    }
                    else
                    {
                        if (job.JobUI.Length > 0)
                        {
                            Zoo.StartExternalViewer(job.FileName).WaitForExit();
                        }

                        job.Dispose();
                    }
                    break;

                default:
                    force = true;
                    continue;
                }
            }
        }