private Task <NativeMethods.IUpdateCollection> SearchWindowsUpdateAsync(NativeMethods.IUpdateSession3 updateSession) { var updateSearcher = updateSession.CreateUpdateSearcher(); TaskCompletionSource <NativeMethods.IUpdateCollection> tcs = new TaskCompletionSource <NativeMethods.IUpdateCollection>(); var job = updateSearcher.BeginSearch(this.queryString, new SearchCompletedCallback(updateSearcher, tcs), null); return(tcs.Task); }
private Task <NativeMethods.IDownloadResult> DownloadUpdateAsync(NativeMethods.IUpdateSession3 updateSession, NativeMethods.IUpdate update) { NativeMethods.IUpdateDownloader updateDownloader = updateSession.CreateUpdateDownloader(); updateDownloader.Updates = (NativeMethods.IUpdateCollection) new NativeMethods.UpdateCollection(); updateDownloader.Updates.Add(update); TaskCompletionSource <NativeMethods.IDownloadResult> tcs = new TaskCompletionSource <NativeMethods.IDownloadResult>(); var job = updateDownloader.BeginDownload( new DownloadProgressCallback(), new DownloadCompletedCallback(updateDownloader, tcs), null); return(tcs.Task); }
public UpdatePackageRetriever() { this.queryString = string.Format(queryStringFormat, Constants.WUSCoordinator.CategoryId); this.updateSession = (NativeMethods.IUpdateSession3) new NativeMethods.UpdateSession(); this.updateSession.ClientApplicationID = "Upgrade Service"; }