Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would probably fire another event when you get the result.</p> <pre><code>public void onEventBackgroundThread(MyEvent event) { doSomeLongRunningProcess(); EventBus.getDefault().post(new MyEventResult()); } </code></pre> <p><strong>Be aware though</strong>: <a href="http://greenrobot.org/eventbus/documentation/delivery-threads-threadmode/" rel="nofollow">reading the docs</a>, you find this:</p> <blockquote> <p><strong>BackgroundThread</strong>: Subscriber will be called in a background thread. If posting thread is not the main thread, event handler methods will be called directly in the posting thread. If the posting thread is the main thread, <strong>EventBus uses a single background thread that will deliver all its events sequentially</strong>. Event handlers using this mode should try to return quickly to avoid blocking the background thread.</p> </blockquote> <p>If you take a long time in this method, other EventBus callbacks will be delayed which will probably translate to an unresponsive application.</p> <p>You probably want to use onEventAsync:</p> <blockquote> <p><strong>Async</strong>: Event handler methods are called in a separate thread. This is always independent from the posting thread and the main thread. Posting events never wait for event handler methods using this mode. Event handler methods should use this mode if their execution might take some time, e.g. for network access. Avoid triggering a large number of long running asynchronous handler methods at the same time to limit the number of concurrent threads. EventBus uses a thread pool to efficiently reuse threads from completed asynchronous event handler notifications.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload