How do you handle forked operations from TestCase point of view, when the test expects a value to assert from an asynchronous operation?

On Jan 25, 2018 10:41, "Andrei Stebakov" <lispercat@gmail.com> wrote:
Thanks, Sven, got it

On Jan 25, 2018 10:36, "Sven Van Caekenberghe" <sven@stfx.eu> wrote:
Hi Andrei,

> On 25 Jan 2018, at 16:26, Andrei Stebakov <lispercat@gmail.com> wrote:
>
> I have written some code that has a deep nested loop of calling ZnClient>>get.
> In the loop I also execute Transcript>>show but I can only see the transcript output after a few seconds when the loop is finished. During all that time while the loop is busy the UI is also unresponsive.
> Is there a way to execute code in some sort of asynchronous way?

The problem is not specific to using ZnClient, it is with every loop you execute in the UI thread: the Transcript output is not updated (as it is the UI thread itself that has to do the drawing).

For example, try

�� 1 to: 10 do: [ :i | Transcript crShow: i. 5 seconds wait ].

The solution is to run you long running code in another thread, like this

�� [ 1 to: 10 do: [ :i | Transcript crShow: i. 5 seconds wait ] ] fork.

HTH,

Sven