AsyncTask causes MainLoop and UI to pause while In Progress

Hi Guys,
Looking at this patch you will quickly notice that stopwatch and lfo stop running when task is in progress. I also noticed that the task needs more time to complete each time it executes. I am pretty shure that it has somethin to do with calling an interace within async but i can’t explain to myself why.
I Tested it both on gamma 1.0 and 2.0 so I’m pretty shure it is not a bug but that i just don’t get something…

Any help would be highly appreciated!

FunctionalStrategyPatternSimpleExample.vl (69.2 KB)

I attached a screenshot for convenience:

this is only an effect from the IOBox, which is nothing else as a constant in the code and triggers a recompile on change. if you change the value dynamically in code it all runs smoothly. see patch:

FunctionalStrategyPatternSimpleExample2.vl (72.8 KB)

1 Like

Ah alright I understand. And as I see you put the whole Process in Async!
And I have a theory about Async Task having longer Execution times:
I changed all classes to Records and now avg. execution Time is at 0.02 Sec.
Could it be that when using classes within an Interface you would need something like an IDisposable?!
Because when using classes Execution time increases with each task significantly and is at ~ 1 sec after several hits…

this is not an easy one, the problem is that you store a Sequence. a sequence can by anything, and in the case of the OrderBy, it outputs a sequence that is only a lazy computation that will order the elements when iterated. so now you store this computation in a pad, read it and pass it on to the next OrderBy, which is then a computation of a computation… and so on. each time it will add more instructions but never actually do something. only the ForEach loop will execute the accumulated OrderBy instructions when iterating it. so, if you want the sort to happen immediately put a ToList or so below it to directly run the sort.

it is generally not the best practice to output a sequence since it doesn’t tell the caller what to expect. better output a Spread, List… any concrete collection. the general rule is: output type as specific as possible, input type as general as possible.


or even better, change the interface to output a concrete collection, so it is clear that the Sort actually does the work.

FunctionalStrategyPatternSimpleExample3.vl (72.8 KB)

also see the remarks here, almost all sequence nodes are lazy:


G-sus. This makes so much sense now! Of course! Okay. Mega pumped to explore this further tomorrow.
Thank you for your kind help with this and taking so much time!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.