Logo

Programming-Idioms

History of Idiom 45 > diff from v11 to v12

Edit summary for version 12 by :

Version 11

2015-08-23, 08:17:15

Version 12

2015-08-23, 10:10:32

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