title: WPF opening new window on current window close in loop
body: <p>I am working on a program that reads a text file and stores parts of it in chunks in an array and then (this is the theory) parses the text in each block (index) and populates a series of textboxes with the parsed data. Because each block will contain data of the same fields, my idea is to open a new window when the user closes the current one and process the data in the next index. This will continue until the array's length has been reached.</p>
  
  <p>My issue is that I don't know to open a new window and increment the array's index for an unknown number of indices.</p>
  
  <p>This is my code for storing the chunks:</p>
  
  <pre><code>            using (StreamReader r = new StreamReader(fname))
              {
  
                  string input = File.ReadAllText(fname);//read through file
  
                  String[] vArray = input.Split(new string[] { "BEGIN:VCARD" }, StringSplitOptions.None); ...
  </code></pre>
  
  <p>and then my code for processing it is:</p>
  
  <pre><code>                            int i;
  
                          parser(vArray[1]);
  
                          MainWindow a = new MainWindow();
                          a.parser(vArray[2]);
                          a.Show();
  
                          for (i = 1; i &lt; vArray.Length - 2; i++)
                          {                                
                              a.Closing += delegate(object sender, System.ComponentModel.CancelEventArgs e)
                              {
                                  MainWindow b = new MainWindow();
                                  b.parser(vArray[i++]);
                                  b.Show();
                              };
                          }
  </code></pre>
  
  <p>This seems really obvious, but I just can't seem to get it :) Any help would be welcomed and appreciated.</p>