title: Count number of instances of C# WPF form application
body: <p>I am trying to count number of instances of C# WPF default public partial class , i.e Mainwindow class.  I tried using static variable to get the count but the count of static variable is also initialized every time an instance of the class is called.
  Below is my code :-</p>
  
  <pre><code>public partial class MainWindow : Window
  {
      private static int instances;
      string[] word = { "PRMTCMOU", "POLATP", "RMHTOEBDAOR", "EMSOU", "DEKBYRAO",                              "CEOSPSRO", "YREOMM", "LAERWINEA", "TSRMOFCOI", "TROMINO" };
      int i = 1;
      bool checkStrings = false;
      int score = 0;
      private Socket tcpsocket;
      TcpClient tcpClient;
  
      public MainWindow()
      {
          instances++;
          InitializeComponent();
          this.Loaded += MainWindow_loaded;
          this.Closed += MainWindow_Closed;
          this.Closing += MainWindow_Closing; 
      }
  }
  </code></pre>