From d092e0d4028830c5fe7963fb3c9ec8590bfef3c7 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Mon, 26 Nov 2018 13:44:13 +0000 Subject: [PATCH] Remove SpinWait Use Task.Wait instead to avoid CPU use. --- .../Mono.Addins.Setup/AddinStore.cs | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Mono.Addins.Setup/Mono.Addins.Setup/AddinStore.cs b/Mono.Addins.Setup/Mono.Addins.Setup/AddinStore.cs index cc8a1dae..ddf6cf4c 100644 --- a/Mono.Addins.Setup/Mono.Addins.Setup/AddinStore.cs +++ b/Mono.Addins.Setup/Mono.Addins.Setup/AddinStore.cs @@ -643,8 +643,7 @@ internal string DownloadFile (IProgressMonitor monitor, string url) try { monitor.BeginTask ("Requesting " + url, 2); var task = DownloadFileRequest.DownloadFile (url, noCache: true); - if (!WaitForTask (task, monitor)) - throw new InstallException ("Installation cancelled."); + task.Wait (); using (var request = task.Result) { monitor.Step (1); @@ -679,19 +678,6 @@ internal string DownloadFile (IProgressMonitor monitor, string url) } } - static bool WaitForTask (Task task, IProgressMonitor monitor) - { - bool result = SpinWait.SpinUntil (() => { - return monitor.IsCancelRequested || task.IsCompleted || task.IsFaulted; - }, 100000); // Use same default timeout as HttpClient. - - if (monitor.IsCancelRequested) - return false; - if (!result) - throw new InstallException ("Timed out."); - return result; - } - internal bool HasWriteAccess (string file) { FileInfo f = new FileInfo (file);