Skip to content

Commit f788c27

Browse files
committed
add examples for execute_ APIs
1 parent 3ce2039 commit f788c27

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

python/mainthread.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ def execute_on_main_thread(func):
6565
on the main Binary Ninja thread.
6666
6767
.. warning:: May be required for some GUI operations, but should be used sparingly as it can block the UI.
68+
69+
:Example:
70+
>>> # Execute a GUI operation on the main thread
71+
>>> import binaryninjaui
72+
>>> from binaryninja import execute_on_main_thread
73+
>>> execute_on_main_thread(lambda: binaryninjaui.UIContext.activeContext().openFileContext(context))
6874
"""
6975
action = scriptingprovider._ThreadActionContext(func)
7076
obj = core.BNExecuteOnMainThread(0, action.callback)
@@ -79,6 +85,12 @@ def execute_on_main_thread_and_wait(func):
7985
executed on the main Binary Ninja thread and will block execution of further python until the function returns.
8086
8187
.. warning:: May be required for some GUI operations, but should be used sparingly as it can block the UI.
88+
89+
:Example:
90+
>>> # Execute a GUI operation and wait for it to complete
91+
>>> import binaryninjaui
92+
>>> from binaryninja import execute_on_main_thread_and_wait
93+
>>> execute_on_main_thread_and_wait(lambda: binaryninjaui.UIContext.activeContext().rebaseCurrentView(0x800000))
8294
"""
8395
action = scriptingprovider._ThreadActionContext(func)
8496
core.BNExecuteOnMainThreadAndWait(0, action.callback)

0 commit comments

Comments
 (0)