def gui_thread_schedule_async(
    func: Callable[..., T], args: tuple[Any, ...] | None = None, kwargs: dict[str, Any] | None = None
) -> None:
    """
    Schedules the given callable to be executed on the GUI thread. If the current thread is the GUI thread, the callable
    is executed immediately. Otherwise, the callable is executed as an event on the GUI thread.

    :returns: None
    """
    if is_gui_thread():
        func(*(args or ()), **(kwargs or {}))
        return

    event = ExecuteCodeEvent(func, args=args, kwargs=kwargs, async_=True)

    with contextlib.suppress(RuntimeError):  # the application is exiting and the main window has been destroyed.
        QCoreApplication.postEvent(GlobalInfo.main_window, event)

    Schedules the given callable to be executed on the GUI thread. If the current thread is the GUI thread, the callable
    is executed immediately. Otherwise, the callable is executed as an event on the GUI thread.

    :returns: None
    
angrmanagement/logic/threads.py