Background Task || Help me understand this please.
-
I have a heavy token parsing function that crashes when I query large directories. I was told to execute this function on a 'background thread' so I've been looking into it. I just need some clarification from someone with experience with this please.
I have this function:
inline function onbtnFindTokenControl(component, value) { // Search files here } btnFindToken.setControlCallback(onbtnFindTokenControl);This function is triggered with a Button on my interface labeled "LOAD".
Based on what i've read so far....is this pretty much how you do this?
inline function onbtnFindTokenControl(component, value) { // Search files here } btnFindToken.setControlCallback(onbtnFindTokenControl); BackgroundTask.callOnBackgroundThread(onbtnFindTokenControl); // I could put this into the button callback and changed my button callback to // a regular inline function.....is this correct? -
@Chazrox place your parsing code in a separated function. Then in the button callback, call the background task for the parsing function.
You shouldn't pass the button callback itself -
@ustk Sweet. So other than that, is that pretty much the process?
I have helper functions that are called inside of my parsing script but exist outside of my function. Do those need to be dealt with specifically or are they automatically handled on the background thread also because they are called from within my background function?
-
I think im confused how to name the functions properly.....


-
@Chazrox You cannot declare a variable that has the same name of an existing function
The background task is one thing, the function you want to run in the background is another thing, and the button callback is another one.place your process in a function like
myParsingProcess, then from within the button callback, just call 'bgFindTokens.callOnBackgroundThred(FindTokens)`Your button's function looks very weird, because you return when value is false, so you don't need an if statement after that. Also, you will never enter the
else(because it means value is false so you already returned. -
@Chazrox Don't mess around with the timeOut and forwardStatus until you get the simple version working

const var BGT = Engine.createBackgroundTask("BGT"); inline function timeCriticalProcess() { Console.print("> VERY CRITICAL :)"); } inline function onButton1Control(component, value) { if (value) BGT.callOnBackgroundThread(timeCriticalProcess); }; Content.getComponent("Button1").setControlCallback(onButton1Control); -
@ustk I ended up figuring it out. I had it all twisted up. lol. I get it a little bit now tho. Thanks!

-
@Chazrox I cooked up a little snippet:
HiseSnippet 1213.3ocsVktbaaCDFT1LMj8HMyz92Nn5WzMdbjZ7YcSssNrqlDcLlJYZ6ex.QBJgwP.Z.AislL9MnOT8QoOB8MncAI0gskuzLU+PRK1qu8.6hNJY.MNVpPVtcGOhhr9Ba+wB8fpCHLApQMj02Z2qeWR7Y9rgi3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