mos Posted May 9, 2018 Posted May 9, 2018 Can I call Sleep(500); in a UniGui application if I need to add a delay inside a for loop, or do I need use some other UniGui function instead? Quote
tappatappa Posted May 9, 2018 Posted May 9, 2018 I'd use Sleep() for debugging purposes only. You should test whether it hangs the whole server or not (call a long Sleep and open a new connection on a separate window). Quote
Ron Posted May 9, 2018 Posted May 9, 2018 As far as I understand, Unigui is a multithreaded system, so you can sleep in all spawned threads, that is in uniMainModule and all forms which run under it. But in the ServerModule it is a different issue, and I would only use sleep in the OnHTTP events, which probably spawn a new thread. Sleeping elsewhere in the ServerModule will probably halt the server, in the sense that new threads/connections/sessions may not be started, but I have not tested this, and also I do not see the point of sleeping other places, like in Create or the other events. If doing HTTP longpolling, you have to sleep in the OnHTTP events, to keep the connection. Quote
GerhardV Posted May 9, 2018 Posted May 9, 2018 Can I call Sleep(500); in a UniGui application if I need to add a delay inside a for loop, or do I need use some other UniGui function instead? The actual question is why do you need a sleep delay inside a loop? If you are waiting for something to "happen" or "catch up" before you can continue then you need to have to look at your design again. Quote
pedrisco Posted May 11, 2018 Posted May 11, 2018 Once i had to deal with legacy and custom libraries for serial communicaction, so i was forced to use "sleep", just avoid the use of "Application.ProcessMessages". Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.