Owin Hosting - CallCancelled CancellationToken

I am trying to understand how to use IOwinRequest.CallCancelled CancellationToken IOwinRequest. I assumed that the token will be marked at any time when the request becomes invalid (for the following cases):

  • Disposal of the object returned by WebApp.Start.
  • The HttpClient.GetAsync task is canceled or deleted.

In all of these cases, it seems that the CallCancelled request has never been flagged. Why?

EDIT: I found an error in my code, and my first item, "Recycling the object returned by WebApp.Start" now works. Rejected / canceled client requests still do not trigger a server request token, though.

For some background, I'm trying to implement a long poll when the server paused the request flow until some data appears to be returned to the client, or if the request is canceled. To implement this, my paused loop will drop out if the cancel marker is flagged. If it is not checked, the request flow will NEVER end unless there is something to return. Since the token is never flagged, my server can end with an infinite number of requests that never end.

+6
source share

Source: https://habr.com/ru/post/956502/


All Articles