Cancellation of Windows Runtime activities is asynchronous
Cancellation of Windows Runtime activities is inherently asynchronous, meaning that after requesting cancellation, the operation may not terminate immediately. This requires developers to properly handle the asynchronous nature of cancellation in their code.
Background
- The Windows Runtime (WinRT) is a programming model introduced in Windows 8 that allows apps written in different languages (C++, C#, JavaScript) to call system features via a common API. Cancellation here refers to stopping an in-progress async operation (like reading a file or fetching network data).
- Unlike traditional synchronous cancellation (where cancel() immediately stops work), WinRT cancellation is asynchronous: calling cancel() signals the operation to stop, but the operation itself must check this signal cooperatively and then notify the caller that it has completed (or faulted). This means the caller must await or handle a completion callback even after issuing a cancel.
- The author, Raymond Chen, is a veteran Microsoft developer known for his long-running blog "The Old New Thing," which explains Windows internals and API design decisions in deep, often quirky detail. His audience is experienced Windows developers.
The Windows Runtime cancellation model is asynchronous: calling cancel merely signals the request and returns immediately, without waiting for the operation to actually stop.
The post discusses the reasoning behind choosing which register to use when passing the desired stack allocation size for stack limit checking in Windows.
PHP typically sends HTTP headers only when a script finishes, causing delays for redirects after long operations. The article notes this issue and mentions that complex workarounds exist for sending headers before script completion.