public Result <T> RunSteps(TransferTask task, Step <T>[] steps, UpdateProgressHandler update) { var ctx = CreateContext(task); var result = Fail("unknown", WorkerStatus.UNKNOWN); for (var i = 0; i < steps.Length; i++) { var step = steps[i]; var stepNo = i + 1; var info = StepInfo.From <T>(step); update(stepNo, info.Desc, WorkerStatus.IN_PROCESS); result = Retry(ctx, task, step, info); //??? try { result.Status.CurrentStep = stepNo; } catch (Exception) { //skip } if (!result.IsSuccess) { break; } } Dispose(ctx, result); return(result); }
protected virtual void OnProgress(ProgressInfo progressInfo) { UpdateProgressHandler handler = this.Progress; if (handler != null) { handler(progressInfo); } }
private void UpdateProgressInfo(String title, Int32 step) { if (this.InvokeRequired) { UpdateProgressHandler ssvh = new UpdateProgressHandler(UpdateProgressInfo); this.BeginInvoke(ssvh, title, step); } else { StatusLabel.Text = title; progressBar1.Value = step; } }
public void UpdateProgressBar(String title, Int32 step, Int32 max) { if (ub.InvokeRequired) { UpdateProgressHandler ssvh = new UpdateProgressHandler(UpdateProgressBar); ub.BeginInvoke(ssvh, title, step, max); } else { ub.SetProgressBar(title, step, max); } Thread.Sleep(600); }
// 开始自动更新,这个时候显示的应该是自动更新界面 public void StartUpdate(UpdateProgressHandler progress, UpdateOverHandler over) { // 读取本地资源文件列表 string txt = ReadLocalFile(GameConfig.FILE_LIST); ParseFile(txt, localFileList); onUpdateProgress = progress; onUpdateOver = over; // 下载服务器的资源文件列表 StartCoroutine(DownloadFile(GetFileServerURL() + GameConfig.FILE_LIST, (WWW w) => { if (w != null && (w.error == null || string.IsNullOrEmpty(w.error)) && w.text != null) { ParseFile(w.text, serverFileList); // 比较资源文件列表,如果需要更新的话,则进行更新 if (CompareVersionList()) { // 使用字符串调用协程以便可以随时停止下载 StartCoroutine("StartDownloading"); } else { // 如果不需要更新的话 直接结束 if (onUpdateOver != null) { onUpdateOver(); } // 没有发现需要更新的文件,把服务器版本号列表写入本地 WriteFile(GameConfig.VERSION_FILE, serverVersion.ToString()); } } else { // 没有找到资源列表文件,直接开始游戏 if (onUpdateOver != null) { onUpdateOver(); } } })); }
public static void UpdateProgress(string message, int value, int max) { UpdateProgressHandler?.Invoke(message, value, max); }