Add mechanism for the UI to run callbacks on the main thread.