title: Wait till Windows Media player ends?
body: <p>I'm so close to complete my program but I have a question.
  Is there anyway that I can pause the loop till All files in Windows Media Player has been played.
  like in process example: </p>
  
  <pre><code>                            process.WaitForExit();
                              while (!process.HasExited)
                                  Thread.Sleep(500);
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>        private bool listbox3job()
          {
              AxWMPLib.AxWindowsMediaPlayer axWmp =
  wfh.Child as AxWMPLib.AxWindowsMediaPlayer;
              DateTime? start = starttid2.Value;
              DateTime? end = sluttid2.Value;
              DateTime now = DateTime.Now;
  
              if (start == null || end == null)
              {
              }
              else if (now &gt;= start.Value &amp;&amp; now &lt;= end.Value)
              {
                  while (DateTime.Now &lt; end.Value) // Loops till DateEndTime.
                  {
                      foreach (var selected in listBox3.Items) // Each file in ItemList.
                      {
                          string s = selected.ToString();
  
                          if (listBox3Dict.ContainsKey(s))
                          {
                              axWmp.URL = (listBox3Dict[s]); //Where all WMP files starts
                          }
                      }
                  }
  
                  return true;
              }
              return false;
          }
  </code></pre>