Beispiel #1
0
        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);
            }
        }
Beispiel #3
0
        /// <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();
            });
        }