private void ReportProgress(long fsize) { float delta; lock (ProgressLock) { Progress += fsize; } Debug.Assert(Progress <= AllFilesSize, string.Format(Localization.Strings.ProgressFail, Progress, AllFilesSize, RoutePath)); if (Progress <= AllFilesSize) { if (AllFilesSize > 0) { PercentProgress = Progress * 100f / AllFilesSize; delta = (float)(fsize * 100.0f / AllFilesSize); } else { PercentProgress = 100f; delta = 100f; } // Invoke progress events ProgressUpdated?.Invoke(PercentProgress); DeltaProgress?.Invoke(delta); } }
private void ReportProgress(long fsize) { float delta; lock (ProgressLock) { Progress += fsize; } Debug.Assert(Progress <= AllFilesSize, "Fatal, Progress is bigger than size of all files! " + Progress + ":" + AllFilesSize + "\nRoute: " + RoutePath); if (Progress <= AllFilesSize) { if (AllFilesSize > 0) { PercentProgress = Progress * 100f / AllFilesSize; delta = (float)(fsize * 100.0f / AllFilesSize); } else { PercentProgress = 100f; delta = 100f; } // Invoke progress events ProgressUpdated?.Invoke(PercentProgress); DeltaProgress?.Invoke(delta); } }
void ApplyDelta() { m_DeltaApplyProgress = new DeltaProgress(); int need_size = (int)(new FileStream(m_DownloadDir + AssetManager.AssetBundleFilename, FileMode.Open, FileAccess.Read, FileShare.Read).Length + new FileStream(unzip_dest_path, FileMode.Open, FileAccess.Read, FileShare.Read).Length) / MEGABYTE; //Debug.LogFormat("[Need Apply Byte:{0}MB] [AvailableSize:{1}MB]", need_size , GetStorageFreeSpace()); if (need_size > GetStorageFreeSpace()) { Popup.Instance.ShowCallbackKey(new PopupCallback.Callback(new Action(Start), null), string.Format("Not Enough Free Space! \n [Need:{0}] [Now Free Space:{1}]", need_size, GetStorageFreeSpace())); return; } #if USE_THREAD Thread th = new Thread(ApplyDeltaThread); th.Start(); #else ApplyDeltaThread(); #endif }
/// <summary> /// Start route crawling /// </summary> /// <returns></returns> public void Start() { Task t = Task.Run(async() => { // If route directory exists if (Directory.Exists(RoutePath)) { try { // Counts size of all files AllFilesSize = CountAllFiles(); // Find all dependencies await GetDependencies(); } catch (Exception e) { if (e.GetType() != typeof(ThreadInterruptedException) && e.GetType() != typeof(ThreadAbortException)) { Trace.Assert(false, string.Format(Localization.Strings.CrawlingRouteFail, RoutePath), e.ToString()); } } // If crawling skipped because cache or inaccuracy, adds to 100 % if (PercentProgress != 100) { DeltaProgress?.Invoke(100f - PercentProgress); PercentProgress = 100; ProgressUpdated?.Invoke(PercentProgress); } } // Crawling complete event Complete?.Invoke(); }); }