Logo

Programming-Idioms

History of Idiom 45 > diff from v13 to v14

Edit summary for version 14 by :

Version 13

2015-08-23, 10:10:53

Version 14

2015-08-23, 10:11:21

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
int compuation() async {
  // ... before ...
  await new Future.delayed(const Duration(seconds : 5));
  // ... after ...
}
Comments bubble
Waiting makes sense in asynchronous code. It's not done that often, and there is no simple primitive for it.
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.