Execution timeout
-
@Lindon ...and the answer was:
for(z=0; z < requiredAmount/100; z++) { for (e = z* 100; e < (z*100)+100; e++) { encryptedSet.push(FileSystem.encryptWithRSA(validSet[e],privateK )); } Console.print("Done:" + (z * 100) + " to:" + ((z*100)+100)); }
I think the vital bit here is selecting a small enough amount of work to do - here 100 encryptions - so that we get through the work without timeout AND get to head back to the outer loopon a regular enough basis to not trigger the timeout there either...
-
@Lindon damn it nope not working...
...so the actual answer was to move the 100 encryptions into a timer callback......
numCallsRequired = validSet.length/100; numCallsExecuted =0; GeneratorPanel.startTimer(3000); // and the timer callback... GeneratorPanel.setTimerCallback(function() { Console.print("EX:"+ numCallsExecuted + " REQ:" + numCallsRequired); if(numCallsExecuted >= numCallsRequired) { GeneratorPanel.stopTimer(); Console.print(encryptedSet.length); encryptedStringValues = encryptedSet.join("\n"); sf = thisAppData.getChildFile(template.ProductName + "_EncryptedSerials.txt"); sf.writeString(encryptedStringValues); }else{ for (e = numCallsExecuted* 100; e < (numCallsExecuted*100)+100; e++) { encryptedSet.push(FileSystem.encryptWithRSA(validSet[e],privateK )); } Console.print("Completed:" + (numCallsExecuted * 100) + " to:" + ((numCallsExecuted*100)+100)); } numCallsExecuted++; });
-
@Lindon Background tasks might be a better solution - but don't ask me how to use them.
-
@d-healey yeah perhaps...
-
@Lindon Definitely use a background task for this, it's a perfect use case. The docs are pretty complete so it should be straightforward to implement.
-
@Christoph-Hart thanks I will give it a go...
-
@Christoph-Hart @d-healey I have an inline function that has some math functions to control 4 parameters (sometimes I need much more than 4) at the same time with just one knob.
I realized that it causes crash in some DAWs when the plugin is used multiple times in a DAW project. When I control 3 or less parameters at the same time, no issues. Because of that I can't finish my plugin.
I think this background tasks can be the solution for these kind of situations. What is the best way to use it, any hints please? The example code is the below:
inline function MultipleMod_Function() { local coeffOne = ((5.344049323286691) * Math.pow((1.469360748201398), (Knob1.getValue()))) * Math.pow((Knob1.getValue()), (-7.134254805322466E-01)); local coeffTwo = ((-6.828519524908431)*Math.pow((1 + ((1.951820425636941E-01)*(Knob1.getValue()))/(-5.344049323286691)), (-1/(1.951820425636941E-01)))); local coeffThree = ((5.071662543519128E-01) + ((4.434246748949629E+02)*Math.pow((Knob1.getValue()), 2.105969454482208)) / (Math.pow(7.670227991996821E+01, 2.105969454482208) + Math.pow((Knob1.getValue()), 2.105969454482208))); local coeffFour = (5.517723965590376E-01) - (1.503463302879198E-01) * Math.exp((-((6.597796821568182E+03) * (Math.pow((Knob1.getValue()), (-6.828519524908431)))))); . . . . . local coeffTwelve = ...etc. EffectModule.setAttribute(EffectModuleIndexOne, (coeffOne - ((coeffThree - coeffTwo)*((Knob2.getValue())-5)/5))); EffectModule.setAttribute(EffectModuleIndexTwo, (coeffFour - ((coeffFive - coeffSix)*((Knob2.getValue())-5)/15))); EffectModule.setAttribute(EffectModuleIndexThree, (coeffSeven - ((coeffEight - coeffNine)*((Knob2.getValue())-5)/2.5))); EffectModule.setAttribute(EffectModuleIndexFour, (coeffTen - ((coeffElev - coeffTwelve)*((Knob2.getValue())-12.5)/5))); }
-
Any ideas @Christoph-Hart about how to use it? I think it would be worth to try.
-
@harris-rosendahl no the crash must come from somewhere else. This is nothing that needs to be pushed to a background task (even if you change hundreds of attributes, it will take a few milliseconds at best).
The background task is for stuff like "Create 50 wave files with 2MB each and fill it with sine waves" that will take 10 seconds or so.
-
@Christoph-Hart I get it thank you.