A function that will synchronously wait

A quick background on my question:

I am trying to write a GPscript that does the following:

   LoadGPPreset(Dexed1, Preset-A)
   process some information about tPreset-A
   LoadGPPreset(Dexed1, Preset-B) 
   process some information about tPreset-B

The problem seems to be that LoadGPPreset() is asynchronous and takes time to load the preset. Meanwhile, my code is continuing to run thinking the preset has already been loaded. There is no way to test to see if the load has been completed. Some similar functions like “SaveStringToTextFile()” return a boolean to tell if the function was successful. Having LoadGPPreset() return a boolean would be nice, but still - how would I wait until the function has completed?

OK, now for the question: Is there a wait function where I can set a wait time and my code will wait until this timer is completed?

A brief meta example:

   LoadGPPreset(Dexed1, Preset-A)
   Wait(750ms)
   process some information about tPreset-A
   LoadGPPreset(Dexed1, Preset-B) 
   Wait(750ms)
   process some information about tPreset-B

I know this example is rudimentary because all kinds of nasty things can happen when waiting on the completion of an I/O event, … but I think you get the idea. :slight_smile:

I’ve had good luck using the Sleep command for such things.
https://gigperformer.com/docs_4_8/SystemFunctionList.html#Sleepmilliseconds%20:%20integer

1 Like

Sounds perfect. Let me give that a try and see if this works. :slight_smile:

I used a 750ms delay. It works perfectly!!! Thank you so much :slight_smile:

1 Like

That’s not a problem - that’s the design — there’s no way to know when a preset has been loaded because a plugin can itself return immediately and do loading in the background (for example), particularly when samples are involved. Even if you could wait, holding up processing will stop GP Script from responding to other callbacks, not something someone one wants in a real-time LIVE performance situation.

That is exactly why the help for that functions states very clearly:

Load a GP plugin preset in the background - seriously experimental and probably very unsafe

As for using the Wait function, that has the same issue - GP Script is suspended for the specified time, preventing response to other callbacks.

Yes, I understood this at the onset … but thanks for the clarification. In my case, my rackspace would not be used in a live environment but in a development environment.

Yes, I understand that but that wouldn’t stop others from trying to use it live (and then complaining when things stop working temporarily).

I’ve thought about providing a notification system for background events (which would work for plugins that don’t return until they’ve finished loading) but unfortunately it’s low priority compared to other things needed by live performers.