public void Update(float deltaTime) { if (!IsStart) { return; } if (mCurLoader == null) { if (WebLoaders.Count > 0) { mCurLoader = WebLoaders[0]; WebLoaders.RemoveAt(0); mCurLoader.Start(); AlreadyLoaders.Add(mCurLoader); } } if (mCurLoader != null) { mCurLoader.Loop(deltaTime); if (mCurLoader.IsDone) { mCurLoader.Close(); mCurLoader = null; } } }
private void SingleLoading(HttpLoad loader) { try { OnSingleLoading?.Invoke(loader); } catch (Exception e) { App.Error(e); } AllLoading(loader); }
public void UnloadAll() { WebLoaders.Clear(); for (int i = 0; i < AlreadyLoaders.Count; i++) { HttpLoad oLoader = AlreadyLoaders[i]; if (oLoader.IsStart) { oLoader.Close(); } oLoader.Clear(); } }
public void LoadAll(HttpPaths[] dirs) { LoadNum = dirs.Length; Urls = new string[LoadNum]; SavePaths = new string[LoadNum]; for (int i = 0; i < dirs.Length; i++) { HttpPaths dir = dirs[i]; Urls[i] = dir.Url; SavePaths[i] = dir.SavePath; HttpLoad oLoader = new HttpLoad(Urls[i], SavePaths[i]); oLoader.SetEventLoading(SingleLoading); oLoader.SetEventLoaded(SingleLoaded); WebLoaders.Add(oLoader); } }
private void SingleLoaded(HttpLoad loader) { if (!string.IsNullOrEmpty(loader.Error)) { loader.Close(); // 下载失败则关闭 Error = Error + "\n" + loader.Error; } OnSingleLoaded?.Invoke(loader); if (LoadIndex == LoadNum) { IsDone = true; } if (IsDone) { OnAllLoaded?.Invoke(this); } }
private void AllLoading(HttpLoad loader) { try { SingleProgress = loader.Progress; mTotalProgress = LoadIndex + SingleProgress; FinalProgress = mTotalProgress / LoadNum; if (loader.IsDone) { LoadIndex = LoadIndex + 1; } OnAllLoading?.Invoke(this); } catch (Exception e) { App.Error(e); } if (IsDone) { Close(); } }
public HttpLoad GetLoader(string url, string savePath) { HttpLoad oLoader = WebLoaders.Find((t) => { return(t.Url == url && t.SavePath == savePath); }); return(oLoader); }