public void Run() { lock (_lockFlag) { _isRunning = true; } UIManager.Current.SetMatchStopButtonStatus(); var pattern = bodyLeft.RegexPattern; var options = bodyLeft.Options; var input = bodyLeft.SourceText; //todo do we allow selection match? var replacement = bodyRight.Replacement; var allowEmptyReplacement = bodyRight.AllowEmptyReplacement; var template = bodyRight.Template; if (pattern == string.Empty) { lock (_lockFlag) { _isRunning = false; } UIManager.Current.SetMatchStopButtonStatus(); MessageBox.Show(ResxManager.GetResourceString(FormStringKeys.STR_MSG_EMPTY_REGEXEXPRESSION)); return; } var info = new RegexFullInfo(pattern, options, input, replacement, allowEmptyReplacement, template, bodyRight.TplPage.TplParameters); _regexInfo = info; if (_threadMatch == null || _threadMatch.IsAlive == false) { _threadMatch = new Thread(RunInternal); _threadMatch.IsBackground = true; _threadMatch.Start(info); } else { UIManager.Current.SetStatusInfo("It's still running..."); } }
private void RunInternal(object itm) { //Thread.Sleep(5000); RegexFullInfo info = itm as RegexFullInfo; if (info == null) { throw new Exception(); } var worker = new RegexWorker(info); var result1 = worker.ExcuteMatches(); if (result1.IsSuccess) { bodyRight.SetMatchResult(info.RegexObj, result1.Data); if (result1.Data != null && result1.Data.Count >= MatchMinCountNeedsDoEvents) { Application.DoEvents(); } var result2 = worker.ExecuteReplace(); if (result2.IsSuccess) { bodyRight.SetReplaceResult(result2.Data); if (result1.Data != null && result1.Data.Count >= MatchMinCountNeedsDoEvents) { Application.DoEvents(); } } var result3 = worker.ExecuteTemplate(); if (result3.IsSuccess) { bodyRight.SetTemplateResult(result3.Data); if (result1.Data != null && result1.Data.Count >= MatchMinCountNeedsDoEvents) { Application.DoEvents(); } } } else { if (null != result1.ErrorMessage) { UIManager.Current.SetStatusInfo(result1.ErrorMessage); } } bodyLeft.RegexExcuted(); lock (_lockFlag) { _isRunning = false; } UIManager.Current.SetMatchStopButtonStatus(); }