On 11/2/16 12:16 PM, Tobias Wolf wrote:
You said I should use ClientAuthDataRunnable::RunOnTargetThread
No, I said that RunOnTargetThread runs on the main thread (and asserts this), which is why it using the prompt service is ok.
how can I run my code using the prompt service and let it run on the main thread?
The point is that there is an nsIRunnable implementation here. This runnable is created, then has NS_DispatchToMainThread called on it. This puts it in the main-thread runnable queue, and eventually its Run() method is called on the main thread. That Run() method then does whatever it wants to.
ClientAuthDataRunnable is subclass of mozilla::psm::SyncRunnableBase, which is a bit more complicated because it allows itself to be dispatched from either mainthread or a background thread, blocks the thread it was dispatched from until the callback completes, etc. But if all you need is to put up a dialog, not block the calling thread, then simply doing a runnable to mainthread to put up a prompt is fine. If you need to block the thread you're on, you will have to duplicate the mozilla::psm::SyncRunnableBase mechanics, or use a subclass of it, or something.
-Boris _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform