This doesn't work:
Debug.Assert(Thread.CurrentThread.Name == "Main Thread"); //doesn't work
//name is null despite name
//in debugger being "Main Thread"
This does work:
Debug.Assert(Thread.CurrentThread.ManagedThreadId == 1);
But I was just wondering:
- a) Is
ManagedThreadId
guaranteed to be1
for the Main Thread? - b) Is there a better way of doing this? Via Attribute would be neatest I feed.
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.