@@ -148,16 +148,13 @@ private async void MainForm_FormClosing(object sender, FormClosingEventArgs e)
148148
149149 #region Menustrip
150150
151- private void selectProcessToolStripMenuItem_Click ( object sender , EventArgs e )
151+ private void attachToProcessToolStripMenuItem_Click ( object sender , EventArgs e )
152152 {
153153 using ( var pb = new ProcessBrowserForm ( nativeHelper , Program . Settings . LastProcess ) )
154154 {
155155 if ( pb . ShowDialog ( ) == DialogResult . OK )
156156 {
157- if ( remoteProcess . Process != null )
158- {
159- remoteProcess . Process . Close ( ) ;
160- }
157+ DetachFromCurrentProcess ( ) ;
161158
162159 remoteProcess . Process = pb . SelectedProcess ;
163160 remoteProcess . UpdateProcessInformations ( ) ;
@@ -171,6 +168,11 @@ private void selectProcessToolStripMenuItem_Click(object sender, EventArgs e)
171168 }
172169 }
173170
171+ private void detachToolStripMenuItem_Click ( object sender , EventArgs e )
172+ {
173+ DetachFromCurrentProcess ( ) ;
174+ }
175+
174176 private void newClassToolStripButton_Click ( object sender , EventArgs e )
175177 {
176178 var node = ClassNode . Create ( ) ;
@@ -562,6 +564,16 @@ internal void DeregisterNodeType(Type type)
562564 memoryViewControl . DeregisterNodeType ( type ) ;
563565 }
564566
567+ /// <summary>Detach from current process.</summary>
568+ private void DetachFromCurrentProcess ( )
569+ {
570+ if ( remoteProcess . Process != null )
571+ {
572+ remoteProcess . Process . Close ( ) ;
573+ remoteProcess . Process = null ;
574+ }
575+ }
576+
565577 /// <summary>Shows the code form with the given <paramref name="generator"/>.</summary>
566578 /// <param name="generator">The generator.</param>
567579 private void ShowCodeForm ( ICodeGenerator generator )
0 commit comments