private static void DownloadInfoFile(object o) { UpdateDownloadInfo dl = (o as UpdateDownloadInfo); if(dl == null) { Debug.Assert(false); return; } dl.ComponentInfo = LoadInfoFile(dl.Url); lock(dl.SyncObj) { dl.Ready = true; } }
DownloadInfoFiles(List <string> lUrls, IStatusLogger sl) { List <UpdateDownloadInfo> lDl = new List <UpdateDownloadInfo>(); foreach (string strUrl in lUrls) { if (string.IsNullOrEmpty(strUrl)) { Debug.Assert(false); continue; } UpdateDownloadInfo dl = new UpdateDownloadInfo(strUrl); lDl.Add(dl); ThreadPool.QueueUserWorkItem(new WaitCallback( UpdateCheckEx.DownloadInfoFile), dl); } while (true) { bool bReady = true; foreach (UpdateDownloadInfo dl in lDl) { lock (dl.SyncObj) { bReady &= dl.Ready; } } if (bReady) { break; } Thread.Sleep(40); if (sl != null) { if (!sl.ContinueWork()) { return(null); } } } Dictionary <string, List <UpdateComponentInfo> > dict = new Dictionary <string, List <UpdateComponentInfo> >(); foreach (UpdateDownloadInfo dl in lDl) { dict[dl.Url.ToLower()] = dl.ComponentInfo; } return(dict); }
private static Dictionary<string, List<UpdateComponentInfo>> DownloadInfoFiles(List<string> lUrls, IStatusLogger sl) { List<UpdateDownloadInfo> lDl = new List<UpdateDownloadInfo>(); foreach(string strUrl in lUrls) { if(string.IsNullOrEmpty(strUrl)) { Debug.Assert(false); continue; } UpdateDownloadInfo dl = new UpdateDownloadInfo(strUrl); lDl.Add(dl); ThreadPool.QueueUserWorkItem(new WaitCallback( UpdateCheckEx.DownloadInfoFile), dl); } while(true) { bool bReady = true; foreach(UpdateDownloadInfo dl in lDl) { lock(dl.SyncObj) { bReady &= dl.Ready; } } if(bReady) break; Thread.Sleep(40); if(sl != null) { if(!sl.ContinueWork()) return null; } } Dictionary<string, List<UpdateComponentInfo>> dict = new Dictionary<string, List<UpdateComponentInfo>>(); foreach(UpdateDownloadInfo dl in lDl) { dict[dl.Url.ToLower()] = dl.ComponentInfo; } return dict; }