What's new
  • Visit Rebornbuddy
  • Visit Resources
  • Visit API Documentation
  • Visit Downloads
  • Visit Portal
  • Visit Panda Profiles
  • Visit LLamamMagic

Thread.Sleep vs...?

xcursedx

Community Developer
Joined
Sep 18, 2015
Messages
28
Reaction score
0
I saw Honorbuddy has an alternative to Thread.Sleep for delaying in apps. I could not find similar functionality in Archebuddy. But according to Honorbuddy store wiki any apps with Thread.Sleep will not be approved. Is there something else I should be using?
 
Pretty sure its fine to go with Thread.Sleep in AB. As AB Plugins are the only thing I do not Code in the Unity Engine my knowledge with non Unity stuff is limited.

In Unity you could just do it with a Coroutine:
void Start()
{
StartCoroutine(Example());
ThreadNotBlocked();
}

IEnumerator Example()
{
DoStuffOne();
yield return new WaitForSeconds(5);
DoStuffAfterWait(); // This will execute 5secs. after yield line was reached.
}

So what this would do is it would execute DoStuffOne() and righter after that it would go on with the Code below StartCoroutine() as is would not block the Thread, 5 secs later, it would executes stuff below the "yield return new WaitForSeconds(5);" Line.

I havent realy looked for a non Unity solution yet as there was no need to keep the main thread unblocked yet, I would however be interested too.
 
Hi, Thread.Sleep is just fine if you're working with normal threads. I would recommend though using Tasks instead, and do Task.Delay(ms, token).Wait(); or simply run it async, await.
 
Back
Top