Add function to run method on main thread.