InvokeOnMainThread() not necessarily invoking on main thread - bug or feature?

I'm using a Timer and let it perform regular checks. If the test condition is true, I start a thread and let it do what it has to do.

If within that thread I want to change the UI I'm using InvokeOnMainThread(). But as the thread was triggered from a Timer which already is a seprate thread, the InvokeOnMainThread() will invoke things on the Timer's thread and not on the real main thread. I work around it by boxing two InvokeOnMainThread() calls.

Is this working as intended or is it a bug in the Mono framework? Is the main thread defined as the one who triggered the current thread or is it supposed to return the "root" thread?


NSObject.InvokeOnMainThread is, mostly, a wrapper around performSelectorOnMainThread:withObject:waitUntilDone:

Quote from documentation:

You can use this method to deliver messages to the main thread of your application. The main thread encompasses the application’s main run loop, and is where the NSApplication object receives events.

We can have a deeper look into it (seems weird) if you fill a bug report on along with a self-contained test case.

Need Your Help

Good interview questions for a Python/TurboGears web developer?

python turbogears

If you were looking to hire a web developer who would primarily be working with TurboGears/Python - what sort of questions should you ask them?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.