Exemplo n.º 1
0
        public Task CalculateFiles(string filePath, string CalculationStopped = null)
        {
            return(Task.Run(() =>
            {
                try
                {
                    if (isWork)
                    {
                        return;
                    }
                    isWork = true;
                    ConcurrentBag <string> DirPaths = FolderManager.GetAllFilesFromSubfolder(filePath);
                    var res = Calculate(DirPaths).Result;
                    Report = new XmlDataWriter();
                    Report.ProcessNotifier += Main_ProcessEventNotifier;
                    Report.GroupAndWriteFiles(res, DataFileName ?? "").GetAwaiter().GetResult();
                }
                catch (Exception e)
                {
                    if (e.InnerException is StopException)
                    {
                        FileProgressNotifier?.Invoke(string.IsNullOrEmpty(CalculationStopped)?"Calculation stopped":CalculationStopped, 0, 100);
                    }
                    if (e.InnerException is ReportException)
                    {
                        throw e;
                    }
                    throw e;
                }
                finally
                {
                    isWork = false;

                    GC.Collect();
                }
            }));
        }
Exemplo n.º 2
0
 private void Main_ProcessEventNotifier(string str, long performed, long maximum)
 => FileProgressNotifier?.Invoke(str, performed, maximum);