title: How to call a public function declared in SecondWIndow from Main WIndow
body: <p>I have 2 Windows in my WPF application. I'm running the <code>SecondWindow</code> from <code>MainWindow</code> using a background <code>thread</code> like as follows.</p>
  
  <pre><code>Thread newWindowThread = new Thread(new ThreadStart(() =&gt;
  {
      SecondWindow sw = new SecondWindow(this);
      sw.Show();
      Dispatcher.Run();
  }));
  newWindowThread.SetApartmentState(ApartmentState.STA);
  newWindowThread.IsBackground = true;
  newWindowThread.Start();
  </code></pre>
  
  <p>and I also have Public Function in the SecondWindow Like this...</p>
  
  <pre><code>public async void hide_animate()
  {
      //Some Stuff//
  }
  </code></pre>
  
  <p>I want to call hide_animate from a <code>method</code> from my <code>MainWindow</code></p>
  
  <p>I tried some options I found by googling, but nothing seems to work. any help?</p>
  
  <p><strong>Update:</strong>
  I've tried this to call the function but still nothing happening...</p>
  
  <pre><code>Window mywindow = FindMyWindow("SecondWindow");
  if (mywindow != null)
  {
      SeocondWinodw.hide_animate();
  }
  
  private Window FindMyWindow(string windowName)
  {
      foreach (Window wnd in System.Windows.Application.Current.Windows)
      {
          if (wnd.Title.ToUpper().Equals(windowName.ToUpper()))
          {
              return wnd;
          }
      }
      return null;
  }   
  </code></pre>