Logo

Programming-Idioms

History of Idiom 45 > diff from v16 to v17

Edit summary for version 17 by :

Version 16

2015-08-25, 20:14:05

Version 17

2015-08-25, 20:15:39

Idiom #45 Pause execution for 5 seconds

Sleep for 5 seconds in current thread, before proceeding with next instructions.

Idiom #45 Pause execution for 5 seconds

Sleep for 5 seconds in current thread, before proceeding with next instructions.

Imports
import "dart:async";
Imports
import "dart:async";
Code
int compuation() async {
  // ... before ...
  await new Future.delayed(const Duration(seconds : 5));
  // ... after ...
}
Code
await new Future.delayed(const Duration(seconds : 5));
Comments bubble
Waiting makes sense in asynchronous code. It's not done that often, and there is no simple primitive for it.

This will not pause the *thread*, but will delay the rest of the current async function.
Comments bubble
Waiting makes sense in asynchronous code. It's not done that often, and there is no simple primitive for it.

This will not pause the *thread*, but will delay the rest of the current async function.