How to cancel Task await after a timeout period
问题 I am using this method to instantiate a web browser programmatically, navigate to a url and return a result when the document has completed. How would I be able to stop the Task and have GetFinalUrl() return null if the document takes more than 5 seconds to load? I have seen many examples using a TaskFactory but I haven\'t been able to apply it to this code. private Uri GetFinalUrl(PortalMerchant portalMerchant) { SetBrowserFeatureControl(); Uri finalUri = null; if (string.IsNullOrEmpty