Designing a blocking method until a value in the dictionary changes
<p>I am currently attempting to design a method that blocks until a value changes in a dictionary. Here I am using the WaitForOpenSpot method.This is only a rough sketch. I am aware that it is currently not thread safe. I'll eventually add the locking/unlocking later. For now I wanted to know if there was a better way of doing this ? Any other suggestions would also be appreciated.</p>

<pre><code>Class AccountStatus
{
  static bool OpenSpot = false;

  static private Dictionary&lt;String, int&gt; Transfer = InitializeContainer();

  static Dictionary&lt;String , int&gt; InitializeContainer ()
  {
       Dictionary&lt;String, int&gt; Transfer = new Dictionary&lt;String, int&gt;()
       Transfer.add("stat",0);
  }

  static void  Changestatus(string str , int val) //str = stat 
  {
      Transfer[str] = val;
      if(val == 1)
      {
          OpenSpot = true
      }        
  } 

  static void WaitForOpenSpot()
  {
      while(!OpenSpot)
      {
          Thread.sleep(2);
      }
  } 
}//end class
</code></pre>
