// File->Create Process handler; display a dialog box allow the // user to create a new process and view its activities. private void _on_file_create_click(Object sender, System.EventArgs e) { CreateProcessDialog cpd = new CreateProcessDialog(); if (cpd.ShowDialog(this) == DialogResult.OK) { try { // if "appName" is null, then "commandLine" is used to determine // the process to create. This simplifies process creation. DebuggedProcess dp = m_events.GetDebugger().CreateProcess( cpd.ApplicationName.Length > 0 ? cpd.ApplicationName : null, cpd.CommandLine, cpd.WorkingDirectory); AppDomainProfilerForm f = _get_form(); f._create_process(new ProcessNode(m_iproc)); Process p = Process.GetProcessById(dp.Id); f.m_procn.SetProcess(p); // f._on_process_attach (dp); } catch (Exception ex) { MessageBox.Show(ex.Message, Localization.GUI_WINDOW_TITLE); } } }
// File->AttachToProcess handler; display a dialog box allowing the // user to select a process to attach to. private void _on_file_attach_click(Object sender, System.EventArgs e) { SelectProcessDialog spd = new SelectProcessDialog(); if (spd.ShowDialog(this) == DialogResult.OK) { foreach (Process p in spd.Processes) { AppDomainProfilerForm f = _get_form(); f._create_process(p); f._on_process_attach(m_events.AttachToProcess(p.Id)); } } }
// Get an "empty" window for an operation, such as process // creation or process attach. // // An "empty" window is a window that isn't currently debugging // a process (m_procn==null). private AppDomainProfilerForm _get_form() { AppDomainProfilerForm f = this; if (f.m_procn != null) { f = new AppDomainProfilerForm(); f.Size = Size; f.BringToFront(); f.Show(); } return(f); }