title: Xamarin iOS Sleep UI thread not working
body: <p>I have a Thread/sleep problem with my Xamarin iOS application. I want to create a simple game, kind of memory game. When pressing the start button there will be 4 buttons which will change it fonts. Start with 1 then 2 and so on. The problem is that I want to have a pause in the method which shows the button, because the user need to see the changed color for a few seconds. I think the multithreading catch up directly the next task so the sleep is gone :( How to fix this? Thanks!</p>
  
  <p>Code:</p>
  
  <pre><code>    partial void btnStart (NSObject sender)
      {
          teller++;
  
          InvokeOnMainThread( ()=&gt; { for (int i = 0; i &lt; teller; i++) {
                  String randomGetal = randomizer();
                  Lijst.Add(new Opslag() {nummerGetal = teller, getal = randomGetal});
                  ThreadPool.QueueUserWorkItem(o =&gt; InvokeOnMainThread(() =&gt; {ButtonColor(randomGetal);}));
          };
          });
          lblRandom1.Text = Lijst.Count.ToString();
      }
  
      public void ClearButton()
      {
          btnA.SetTitleColor (UIColor.Green, UIControlState.Normal);
          btnB.SetTitleColor (UIColor.Green, UIControlState.Normal);
          btnC.SetTitleColor (UIColor.Green, UIControlState.Normal);
          btnD.SetTitleColor (UIColor.Green, UIControlState.Normal);
      }
  
      public void ButtonColor(string a)
      {
  
          if (a == "A") {
              btnA.SetTitleColor (UIColor.Magenta, UIControlState.Normal);
              Thread.Sleep(2000);
              ClearButton ();
          }
  
          if (a == "B") {
              btnB.SetTitleColor (UIColor.Magenta, UIControlState.Normal);
              Thread.Sleep(2000);
              ClearButton ();
          }
  
          if (a == "C") {
              btnC.SetTitleColor (UIColor.Magenta, UIControlState.Normal);
              Thread.Sleep(2000);
              ClearButton ();
          }
  
          if (a == "D") {
              btnD.SetTitleColor (UIColor.Magenta, UIControlState.Normal);
              Thread.Sleep(2000);
              ClearButton ();
          }
      }
  
      public string randomizer()
      {
          int randomNummer = random.Next (0, 4);
          if (randomNummer == 0)
              return "A";
          if (randomNummer == 1)
              return "B";
          if (randomNummer == 2)
              return "C";
          if (randomNummer == 3)
              return "D";
          else
              return "Empty";
      }
  
  }
  
  public class Opslag
  {
      public int nummerGetal {get;set;        
      }
  
      public string getal {
          get;
          set;
      }
  
  }
  </code></pre>
  
  <p>}</p>