title: Passing parameter between classes via delegates or...?
body: <p>I'd need to pass some variables between classes, I have a following code snippet to explain the situation. Note the following code are from app1, the SimpleScene() class is the entry point.</p>
  
  <pre><code>class SimpleScene {
      bool isReady;
      bool result;
  
      Protected override Run() {
          // instance of class StateMonitor
          StateMonitor sm = new StateMonitor;
          Listener(sm);
          sm.proc();
  
          while(!isReady) {}
  
          result = func();
          if (result) {
              // need to inform StateMonitor to do a certain action, e.g. set bool flag = true, and StateMonitor does something iff flag == true;
          }
      }
  
      void OnReady(bool isOnReady) {
          if(isOnReady)
               isReady = true;
      }
  
      Private void Listener(StateMonitor sm) {
          sm.OnReady += new StateMonitor.ready(OnReady);
      }
  
      bool func() {
          //do something...
      }
  
  }
  
  class StateMonitor {
      public delegates void ready(bool isReady);
      public event ready OnReady;
  
      // start app2 as a new process
      public void proc() {
          Process p_app2 = new Process();
          // omit other startinfo for app2.
          p_app2.OutputDataReceived += new DataReceivedEventHandler(outputHandler);
          p_app2.Start();
          p_app2.BeginOutputReadLine();
      }        
  
      public void outputHandler(object sender, DataReceivedEventArgs line) {
          // omit output data line match
          if (OnReady != null)
              OnReady(true);
      }
  }
  </code></pre>
  
  <p>class StateMonitor starts another application - let's say app2 - and read the stdout from app2. Depending on the output string format, it will do different things.</p>
  
  <p>My problem lies in the code comments, where I want to inform StateMonitor to do certain thing once flag == true; How could I do that?</p>
  
  <p>Thank you</p>