Difference between revisions of "User:DavidJCobb/Stack dumping"
→Process a task OnHit, and wait for X seconds during or after the task
imported>DavidJCobb m (→Process a task OnHit, without outright discarding concurrent calls: fixed some more) |
imported>DavidJCobb |
||
Line 43: | Line 43: | ||
=== Process a task OnHit, and wait for X seconds during or after the task === | === Process a task OnHit, and wait for X seconds during or after the task === | ||
This simple example blocks concurrent calls, and replaces a Utility.Wait(X) call with a RegisterForSingleUpdate(X) call. If we used Utility.Wait(X), we'd suspend our stack for X seconds; by using RegisterForSingleUpdate and OnUpdate, we get rid of the stack entirely during those X seconds, and create a new stack to continue processing after the delay. | This simple example blocks concurrent calls, and replaces a Utility.Wait(X) call with a RegisterForSingleUpdate(X) call. If we used Utility.Wait(X), we'd suspend our stack for X seconds; by using RegisterForSingleUpdate and OnUpdate, we get rid of the stack entirely during those X seconds, and create a new stack to continue processing after the delay. | ||
Even if we didn't prevent concurrency using <code>pbBusy</code>, we'd still get rid of all OnHit stacks at the start of the wait, and create just one OnUpdate stack at the end of the wait; however, with every hit, the wait time would be reset to X seconds. | |||
<source lang="Papyrus"> | <source lang="Papyrus"> |