Currently I want to add some code that will run a task every x seconds, without using a delay I tried this:
The code above works (well it waits 5 seconds), then the next code is run - however it freezes the rest of the app from running while it's looping. Is there another way to do the same thing but without freezing the app? (Using a delay/sleep also freezes the app).
This is for nintendo switch payload, also before someone says 'look at hekate' - etc, I already did, but that doesn't help. I just need a short example and a different approach, I'm not a C coder - so that's why I don't know another way to do this.
Code:
u32 runningtime = get_tmr_us() / 1000000;
int delay = 5; // delay in seconds
int total = runningtime + delay;
while (((u32) get_tmr_us() / 1000000) < total)
{
//do nothing
}
//code runs here after 5 seconds
The code above works (well it waits 5 seconds), then the next code is run - however it freezes the rest of the app from running while it's looping. Is there another way to do the same thing but without freezing the app? (Using a delay/sleep also freezes the app).
This is for nintendo switch payload, also before someone says 'look at hekate' - etc, I already did, but that doesn't help. I just need a short example and a different approach, I'm not a C coder - so that's why I don't know another way to do this.