When an asynchronous operation takes time, repeatedly checking its status wastes effort. The completed event pattern waits for the resource to signal that the operation has finished. section 21.4.2 section 21.5
A practical approach:
- Use a completion event when the resource provides one; it avoids a polling loop and can notify as soon as the operation completes. section 21.4.2 section 21.5
- Keep an overall timeout: an operation may never complete, leaving the notification unreceived. section 21.4.2
- For a resource without events that is used repeatedly, consider a façade that performs active waiting and exposes the result as a completion event. section 21.4.2
File changes
A file-system watcher can notify automation code when a file changes, avoiding repeated checks of its last-write time. section 21.4.2
