I think there is a better way to get the CancellationToken
:
var properties = new AppProperties(app.Properties);
CancellationToken token = properties.OnAppDisposing;
AppProperties
is under namespace Microsoft.Owin.BuilderProperties
, which comes from this nuget package: http://www.nuget.org/packages/Microsoft.Owin/
The description of property OnAppDisposing
says:
Gets or sets the cancellation token for “host.OnAppDisposing”.
Please refer to: http://msdn.microsoft.com/en-us/library/microsoft.owin.builderproperties.appproperties%28v=vs.113%29.aspx