title: How do i implement a time delay?
body: <p>I'm 3 weeks into programming now so I tried to build a memory game.
  Everything works fine except the delay. I've tried many different options but somehow the delay is at the end of the <code>Button_Click</code> event.</p>
  
  <p>If I click the first button it changes the content but when I click the 2nd 
  button no matter which <code>if</code> statement triggers, the 2nd card doesn't show. The code works fine until the end of the event THEN the delay of 3 sec happens</p>
  
  <p>What I want to achieve is that you can see the 2nd card a short amount of time 
  before both cards are turned back over or disappear.</p>
  
  <p>P.S. - It seems to work if i add a <code>MessageBox</code> after the "delay"
  but that's not the goal, so is there something like a wait for sync or something that I missed?</p>
  
  <p>Code:</p>
  
  <pre><code>private void Button_Click(object sender, RoutedEventArgs e)
          {
              var button = (Button)sender;
              int index = ContainderGrid.Children.IndexOf(button);
  
              mCounterSecondPic++;
  
              button.Content = new BitmapImage(new Uri(mImgPath[mPairs[index]]));//change content
              mPic[mCounterSecondPic-1] = mPairs[index];
              button.IsEnabled = false;
  
              if (mPic[0] == mPic[1] &amp; mCounterSecondPic == 2)
              {
  
                  mCounterSecondPic = 0;
  
                  new System.Threading.ManualResetEvent(false).WaitOne(3000); //wait for 3sec
  
                  ContainderGrid.Children.RemoveAt(mPairs.IndexOf(mPic[0]));
                   mPairs.RemoveAt(mPairs.IndexOf(mPic[0]));
                   ContainderGrid.Children.RemoveAt(mPairs.IndexOf(mPic[0]));
                   mPairs.RemoveAt(mPairs.IndexOf(mPic[0]));
  
              }
  
              if (mCounterSecondPic == 2 &amp; mPic[0] != mPic[1])
              {
  
                  mCounterSecondPic = 0;
  
                  new System.Threading.ManualResetEvent(false).WaitOne(3000);//wait for3 sec
  
                  ContainderGrid.Children.Cast&lt;Button&gt;().ToList().ForEach(resetbuttons =&gt;
                  {
                      resetbuttons.IsEnabled = true;
                      resetbuttons.Content = new BitmapImage(new Uri(mCardBack));
  
                  });
  
  
              }
  </code></pre>
  
  <p>ps: it seems to work if i add a messageBox before the "delay"
  but thats not the gole, so is there something like a wait for sync or something i missed?</p>
  
  <pre><code>                MessageBox.Show("x");
                  new System.Threading.ManualResetEvent(false).WaitOne(3000);
  
  </code></pre>