From f788c27bcb8851f594b63ccb2cca51887996f431 Mon Sep 17 00:00:00 2001 From: Jordan Wiens Date: Fri, 5 Dec 2025 17:19:13 -0500 Subject: add examples for execute_ APIs --- python/mainthread.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'python/mainthread.py') diff --git a/python/mainthread.py b/python/mainthread.py index 96786342..298d9cf0 100644 --- a/python/mainthread.py +++ b/python/mainthread.py @@ -65,6 +65,12 @@ def execute_on_main_thread(func): on the main Binary Ninja thread. .. warning:: May be required for some GUI operations, but should be used sparingly as it can block the UI. + + :Example: + >>> # Execute a GUI operation on the main thread + >>> import binaryninjaui + >>> from binaryninja import execute_on_main_thread + >>> execute_on_main_thread(lambda: binaryninjaui.UIContext.activeContext().openFileContext(context)) """ action = scriptingprovider._ThreadActionContext(func) obj = core.BNExecuteOnMainThread(0, action.callback) @@ -79,6 +85,12 @@ def execute_on_main_thread_and_wait(func): executed on the main Binary Ninja thread and will block execution of further python until the function returns. .. warning:: May be required for some GUI operations, but should be used sparingly as it can block the UI. + + :Example: + >>> # Execute a GUI operation and wait for it to complete + >>> import binaryninjaui + >>> from binaryninja import execute_on_main_thread_and_wait + >>> execute_on_main_thread_and_wait(lambda: binaryninjaui.UIContext.activeContext().rebaseCurrentView(0x800000)) """ action = scriptingprovider._ThreadActionContext(func) core.BNExecuteOnMainThreadAndWait(0, action.callback) -- cgit v1.3.1