title: Static class / Object? How to dispose
body: <p>i'm really struggeling with OOP. I would like to start a process in my additional class. The process is a shell and I need to access this shell from severel forms and classes to write the commands and to receive the output. I use events to get the data. Here is my class for the process.</p>
  
  <p>My class for the </p>
  
  <pre><code>public class ADBShell 
  {
  
      public static string output = String.Empty;
      public static Process adbshell = new Process();
  
  
  
      public void Start_ADBShell()
      {
          if (adbshell != null &amp;&amp; !adbshell.HasExited)
              return;
  
          adbshell = new Process();
          adbshell.StartInfo.UseShellExecute = false;
          adbshell.StartInfo.FileName = @"D:\adb\adb.exe";
          adbshell.StartInfo.Arguments = "shell";
          adbshell.StartInfo.RedirectStandardOutput = true;
          adbshell.StartInfo.RedirectStandardInput = true;
          //adb.StartInfo.RedirectStandardError = true;
          adbshell.EnableRaisingEvents = true;
          adbshell.StartInfo.CreateNoWindow = true;
          //adb.ErrorDataReceived += new DataReceivedEventHandler(adb_ErrorDataReceived);
          adbshell.OutputDataReceived += new DataReceivedEventHandler(adbshell_OutputDataReceived);
  
  
          try { var started = adbshell.Start(); }
          catch (Exception ex)
          {
  
  
              Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
          }
  
          //adb.BeginErrorReadLine();
          adbshell.BeginOutputReadLine();
  
      }
  
      void adbshell_OutputDataReceived(object sender, DataReceivedEventArgs e)
      {
  
          output += (e.Data) + Environment.NewLine;
  
      }
  
     public void press_touch(string x, string y)
      {
          adbshell.StandardInput.WriteLine("input tap " + String.Format("{0} {1}", x, y));
          Debug.WriteLine("pressed");
      }
  </code></pre>
  
  <p>}</p>
  
  <p>My Form class looks like</p>
  
  <pre><code>public partial class Form1 : Form
  {
          private bool _record;
          private bool _selecting;
  
          private Rectangle _selection;
  
          //---------------------------------------------------------------------
          public Form1()
          {
              InitializeComponent();
  
          }
  
          //---------------------------------------------------------------------
  private void Form1_Load(object sender, System.EventArgs e)
  {
    ADBShell adbshell = new ADBShell();
    adbshell.Start_ADBShell();
  
  }
  </code></pre>
  
  <p>Everytime I have to make a new object in my methods, but i dont want to create everytime a new object. I would like make one time the object and access everytime to the same object. I do not want to make servel processes. I need only proccess and send and receive everytime the data to this process. </p>
  
  <ol>
  <li>Do I have to make a static class?</li>
  <li>How I can dispose and close my process after I'm quit my Form Class?</li>
  </ol>