Slide 52
Slide 52 text
class ExampleThreadCommand(sublime_plugin.WindowCommand):
def run(self):
thread.start_new_thread(self.in_new_thread, ())
def in_new_thread(self):
sublime.set_timeout(self.in_main_thread, 0)
def in_main_thread(self):
self.window.show_input_panel("Hello from the main
thread!", "", None, None, None)
Calling UI Components on other Thread (2)
• UI components must be called in `main thread`.
• Use 'sublime.set_timeout(callback, delay)' for it.
• When it's some dialog component, to make matters worse, the whole
editor can block and won't return to the `main thread`