title: How do I assert that the code is running in the main thread?
body: <p>This doesn't work:</p>
  
  <pre><code>Debug.Assert(Thread.CurrentThread.Name == "Main Thread"); //doesn't work
                       //name is null despite name
                       //in debugger being "Main Thread"
  </code></pre>
  
  <p>This does work:</p>
  
  <pre><code>Debug.Assert(Thread.CurrentThread.ManagedThreadId == 1);
  </code></pre>
  
  <p>But I was just wondering:</p>
  
  <ul>
  <li>a) Is <code>ManagedThreadId</code> guaranteed to be <code>1</code> for the Main Thread?</li>
  <li>b) Is there a better way of doing this? Via Attribute would be neatest I feed.</li>
  </ul>
  
  <p>I'm working on a Silverlight project, I haven't tagged as such as I don't know it's relevant, but please comment if you belive there is a difference between Silverlight and other .net runtimes.</p>