示例#1
0
 public Jp2KrDesignVM() : base(null, null)
 {
     Ongoings.Add(new TestLabelProgressVM());
     Ongoings.Add(new TestLabelProgressVM());
     Faults.Add(new TestLabelProgressVM());
     Progress = new TestLabelProgressVM();
 }
示例#2
0
        private Task ParallelForEach(Func <TranslationUnit, Jp2KrWork> genViewModel)
        {
            List <TranslationUnit> transUnits = translations ?? FindTranslations().ToList();
            int complete = 0;

            Progress.Value = 0;
            Progress.Label = $"{workKind}{complete} / {transUnits.Count}";

            return(transUnits.ForEachPinnedAsync(coreCount, async t => {
                Jp2KrWork item = genViewModel(t);
                Ongoings.Add(item.Progress);
                try {
                    await Task.Run(() => item.Process());
                }
                catch (EhndNotFoundException) {
                    Progress.Foreground = LabelProgressVM.FgError;
                    throw;
                }
                catch (Exception e) {
                    Progress.Foreground = LabelProgressVM.FgError;
                    string msg = e is RegexMatchTimeoutException
            ? "정규식 검색이 너무 오래 걸립니다. 정규식을 점검해주세요."
            : e.Message;
                    item.SetProgress(TranslationPhase.Error, 100, msg);
                    Faults.Add(item.Progress);
                    Exceptions.Add(e);
                }
                finally {
                    _ = Ongoings.Remove(item.Progress);
                    complete++;
                    Progress.Value = (double)complete / transUnits.Count * 100;
                    Progress.Label = $"{workKind}{complete} / {transUnits.Count}";
                }
            }));
        }