/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="ParserConnection"/> class. /// This will attempt to connect to an existing parser or start a new one if necessary. /// </summary> /// ----------------------------------------------------------------------------------- // per KenZ, convention is for server to already include the \\SILFW,e.g. HATTON1\\SILFW public ParserConnection(string sServer, String sDatabase, String sLangProj, bool fParseAllWordforms) { m_activity = ""; m_scheduler = ParserFactory.GetDefaultParser(sServer, sDatabase, sLangProj); m_scheduler.ParseAllWordforms = fParseAllWordforms; m_scheduler.ParserUpdateVerbose += ParserUpdateHandlerForPolling; }
/// <summary> /// </summary> /// <param name="parser"></param> /// <param name="task"></param> public void ParserUpdateHandlerForPolling(ParserScheduler parser, TaskReport task) { CheckDisposed(); //store this for clients which just want to poll us, instead of wiring up to the event m_activity = task.Description; m_currentError = task.CurrentError; if (task.NotificationMessage != null && task.Phase != TaskReport.TaskPhase.finished) //keeps us from getting the notification at the end of the task. { m_notificationMessage = task.NotificationMessage; } //will have to do something more smart something when details is used for something else if (task.Details != null) { TraceResult = task.Details; } if (m_currentError != null) { System.Windows.Forms.MessageBox.Show(m_currentError.Message, ParserServiceStrings.ksParserProblem, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public TryAWordWork(ParserScheduler scheduler, string tryAWord, bool doTrace, int[] selectTraceMorphs) : base(scheduler, ParserPriority.TryAWord) { m_tryAWord = tryAWord; m_doTrace = doTrace; m_selectTraceMorphs = selectTraceMorphs; }
// per KenZ, convention is for server to already include the \\SILFW,e.g. HATTON1\\SILFW private ParserScheduler GetDefaultParser1(String sServer, String sDatabase, String sLangProj) { String sKey = MakeKey(sServer, sDatabase, sLangProj); if (m_hParsers.ContainsKey(sKey)) { /* This caused a security problem with at least one machine configuration, so * we no longer want to use it. LT-5599 * System.Diagnostics.EventLog.WriteEntry("ParserFactory", "Gave out existing parser for " + sServer +"-"+sDatabase+"-"+sLangProj); */ ParserScheduler parsched = m_hParsers[sKey]; parsched.AddRef(); return(parsched); } try { ParserScheduler parser = ParserScheduler.CreateInDomain(sServer, sDatabase, sLangProj); m_hParsers.Add(sKey, parser); //System.Diagnostics.EventLog.WriteEntry("ParserFactory", "Created a parser for " + sServer +"-"+sDatabase+"-"+sLangProj); return(parser); } catch (Exception) { //MessageBox.Show("ParserFactory could not start the M3Parser. " + err.Message); throw; } }
public new TimeStamp LoadGrammarAndLexicon(ParserScheduler.NeedsUpdate eNeedsUpdate) { using (new TaskReport("Load Grammar", m_taskUpdateHandler)) { Delay(10000000); return new TimeStamp(m_connection);//DateTime.Now; } }
private void ReleaseScheduler1(ParserScheduler parser) { int cref = parser.SubtractRef(); if (cref <= 0) { m_hParsers.Remove(MakeKey(parser.Server, parser.Database, parser.LangProject)); parser.Dispose(); } }
static public void ReleaseScheduler(ParserScheduler parser) { TheOneInstance.ReleaseScheduler1(parser); // If there are multiple windows open with their own Scheduler, // we shouldn't dispose of the factory too. That will cause the other // parser objects to be disposed out from under the other windows. // See LT-6266. //s_factory.Dispose(); //s_factory = null; }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> private void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (m_isDisposed) { return; } m_clientTaskReportHandler = null; if (disposing) { // Dispose managed resources here. if (m_scheduler != null) { /* Don't know why it tries this, since the Dispose method in the scheduler calls Resume(). * m_scheduler.AttemptToPause(); * while (!m_scheduler.IsPaused) * { * // How long should we wait? * // Or, should we put up a pacifier to let the user knwo we are trying to shut down the parser/ * } */ // Remove event handlers. m_scheduler.ParserUpdateVerbose -= ParserUpdateHandlerForPolling; m_scheduler.ParserUpdateNormal -= ParserUpdateHandlerForPolling; if (m_localTaskReportHandler != null) { m_scheduler.ParserUpdateVerbose -= m_localTaskReportHandler; m_scheduler.ParserUpdateNormal -= m_localTaskReportHandler; } ParserFactory.ReleaseScheduler(m_scheduler); // ReleaseScheduler calls Dispose on m_scheduler. } } // Dispose unmanaged resources here, whether disposing is true or false. m_localTaskReportHandler = null; m_scheduler = null; m_currentError = null; m_activity = null; TraceResult = null; m_notificationMessage = null; m_isDisposed = true; }
/// <summary> /// this will be called from the parser's thread; we need to marshal it to the client's thread /// so that it comes in as a normal event in the event handling loop of the client. /// </summary> /// <param name="parser"></param> /// <param name="task"></param> public void ParserUpdateHandler(ParserScheduler parser, TaskReport task) { CheckDisposed(); if (null == m_clientTaskReportHandler) { return; } lock (this) { //using Invoke () here would cause this thread to wait until the event was handled. ((Control)m_clientTaskReportHandler.Target).BeginInvoke(m_clientTaskReportHandler, new object[] { parser, task }); } //testing //((Control)m_clientTaskReportHandler.Target).Invoke(m_clientTaskReportHandler, new object[] {parser, task}); }
/// <summary> /// /// </summary> internal TimeStamp RetrieveModel(SqlConnection connection, string LangProject, TaskReport parentTask, ParserScheduler.NeedsUpdate eNeedsUpdate) { TimeStamp began = new TimeStamp(connection); using (FdoCache cache = FdoCache.Create(connection.DataSource, connection.Database, null)) { BaseVirtualHandler.InstallVirtuals(@"Language Explorer\Configuration\Main.xml", new string[] { "SIL.FieldWorks.FDO.", "SIL.FieldWorks.IText." }, cache, true); string sDescription; string sFxtFile; SetDescriptionAndFxtFile(eNeedsUpdate, out sDescription, out sFxtFile); using (m_topLevelTask = parentTask.AddSubTask(sDescription)) { m_taskStack.Push(m_topLevelTask); string sFxtPath = Path.Combine(DirectoryFinder.FWCodeDirectory, sFxtFile); m_sFxtOutputPath = Path.Combine(m_outputDirectory, m_database + "ParserFxtResult.xml"); if ((eNeedsUpdate == ParserScheduler.NeedsUpdate.HaveChangedData) && File.Exists(m_sFxtTemplateOutputPath)) { try { DoUpdate(cache, sFxtPath, ref m_modelDom); DoUpdate(cache, m_sGafawsFxtPath, ref m_templateDom); } // (SteveMiller): Unremarked, the following often causes an error: // Warning as Error: The variable 'e' is declared but never used catch (XUpdaterException) { //Trace.WriteLine("XUpdater exception caught: " + e.Message); // do something useful for the user DoDump(eNeedsUpdate, cache, sFxtPath); } } else DoDump(eNeedsUpdate, cache, sFxtPath); } } m_topLevelTask = null; return began; }
protected ParserWork(ParserScheduler scheduler, ParserPriority priority) { m_scheduler = scheduler; m_priority = priority; m_scheduler.IncrementQueueCount(m_priority); }
//this is invoked by the parser connection, on our own event handling thread. protected void ParserUpdateHandler(ParserScheduler parser, TaskReport task) { if (m_previousTask != task) { m_log.Text += "\r\n"; Debug.WriteLine(""); } string pad = ""; for(int i= task.Depth; i>0;i--) pad += " "; m_log.Text+=pad; switch(task.Phase) { case TaskReport.TaskPhase.started: m_log.Text += task.Description+" ";//+pad + "{\r\n"; Debug.Write(task.Description+" "); break; case TaskReport.TaskPhase.finished: if (m_previousTask != task) m_log.Text +=" ^ "; m_log.Text += task.DurationSeconds.ToString()+ " seconds"; Debug.Write(task.DurationSeconds.ToString()+ " seconds"); //m_log.Text += "}\r\n"; if (task.Details != null) m_log.Text += "Details:"+task.Details; break; default: m_log.Text += task.Description+" " + task.PhaseDescription ;//+ "\r\n"; Debug.Write(task.Description+" " + task.PhaseDescription); break; } m_log.Select(m_log.Text.Length,0); m_log.ScrollToCaret(); m_previousTask = task; }
public UpdateWordformWork(ParserScheduler scheduler, ParserPriority priority, IWfiWordform wordform) : base(scheduler, priority) { m_wordform = wordform; }
public ReloadGrammarAndLexiconWork(ParserScheduler scheduler) : base(scheduler, ParserPriority.ReloadGrammarAndLexicon) { }
private void DoDump(ParserScheduler.NeedsUpdate eNeedsUpdate, FdoCache cache, string sFxtPath) { using (XDumper fxtDumper = new XDumper(cache)) { //Trace.WriteLine("Retriever.DoDump"); // N.B. It is crucial to include the ConstraintFilterStrategy here // Without it, we end up passing ill-formed environments to the parser - a very bad thing // See LT-6827 An invalid environment is being passed on to the parser and it should not. fxtDumper.Go(cache.LangProject as CmObject, sFxtPath, File.CreateText(m_sFxtOutputPath), new IFilterStrategy[] { new ConstraintFilterStrategy() }); if (eNeedsUpdate == ParserScheduler.NeedsUpdate.GrammarAndLexicon || eNeedsUpdate == ParserScheduler.NeedsUpdate.LexiconOnly) { StartSubTask(ParserCoreStrings.ksRetrievingTemplateInformation); using (XDumper fxtDumperInner = new XDumper(cache)) { m_sFxtTemplateOutputPath = Path.Combine(m_outputDirectory, m_database + "GAFAWSFxtResult.xml"); fxtDumperInner.Go(cache.LangProject as CmObject, m_sGafawsFxtPath, File.CreateText(m_sFxtTemplateOutputPath)); } EndSubTask(); } } }
protected override void LoadParser(ref XmlDocument model, XmlDocument template, TaskReport task, ParserScheduler.NeedsUpdate eNeedsUpdate) { try { M3ToXAmpleTransformer transformer = new M3ToXAmpleTransformer(m_database); if (eNeedsUpdate == ParserScheduler.NeedsUpdate.GrammarAndLexicon || eNeedsUpdate == ParserScheduler.NeedsUpdate.LexiconOnly || eNeedsUpdate == ParserScheduler.NeedsUpdate.HaveChangedData) { // even though POS is part of Grammar, this is only used by the lexicon DateTime startTime = DateTime.Now; // PrepareTemplatesForXAmpleFiles adds orderclass elements to MoInflAffixSlot elements transformer.PrepareTemplatesForXAmpleFiles(ref model, template, task); long ttlTicks = DateTime.Now.Ticks - startTime.Ticks; Trace.WriteLineIf(tracingSwitch.TraceInfo, "GAFAWS prep took : " + ttlTicks.ToString()); } transformer.MakeAmpleFiles(model, task, eNeedsUpdate); } catch (Exception error) { if (error.GetType() == Type.GetType("System.Threading.ThreadInterruptedException") || error.GetType() == Type.GetType("System.Threading.ThreadAbortException")) { throw error; } task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! throw new ApplicationException("Error while generating files for the Parser.", error); } int maxAnalCount = 20; XmlNode maxAnalCountNode = model.SelectSingleNode("/M3Dump/ParserParameters/XAmple/MaxAnalysesToReturn"); if (maxAnalCountNode != null) { maxAnalCount = Convert.ToInt16(maxAnalCountNode.FirstChild.Value); if (maxAnalCount < 1) maxAnalCount = -1; } try { m_xample.SetParameter("MaxAnalysesToReturn", maxAnalCount.ToString()); } catch (Exception error) { if (error.GetType() == Type.GetType("System.Threading.ThreadInterruptedException") || error.GetType() == Type.GetType("System.Threading.ThreadAbortException")) { throw error; } ApplicationException e = new ApplicationException("Error while setting Parser parameters.", error); task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! throw e; } LoadXAmpleFiles(task); }
//this is invoked by the parser connection, on our own event handling thread. protected void ParserUpdateHandler(ParserScheduler parser, TaskReport task) { Trace.WriteLine(" In ParserUpdateHandler"); try { switch (task.Phase) { case TaskReport.TaskPhase.started: m_lblStatus.Text = m_sParserStatusPrefix + task.Description + m_sParserStatusSuffix; Trace.WriteLine(" started: " + task.Description); break; case TaskReport.TaskPhase.finished: m_lblStatus.Text = m_sParserStatusPrefix + task.Description + m_sParserStatusSuffix; Trace.WriteLine(" finished: " + task.Description); Trace.WriteLine(" finished: Duration: " + task.DurationSeconds.ToString() + " seconds"); Trace.WriteLineIf(task.Details != null, "finished: Details: " + task.Details); break; default: m_lblStatus.Text = m_sParserStatusPrefix + task.Description + m_sParserStatusSuffix; Trace.WriteLine(" default: " + task.Description + " " + task.PhaseDescription); break; } } catch (ObjectDisposedException ode) { // By the time we get any "finished" tasks, they have been disposed. Ignore them. Trace.WriteLine(" " + ode.Message); Trace.WriteLine(" " + ode.StackTrace); } }
protected void AddWords(ParserScheduler.Priority priority) { FdoOwningCollection<IWfiWordform> words = m_selectedFdoCache.LangProject.WordformInventoryOA.WordformsOC; if (words.Count == 0) { MessageBox.Show("Can't do that, because there are no wordforms in this project."); return; } Random r = new Random(); for(int i = 0; i < 10; i++) { int index = r.Next(0, words.Count - 1); int hvo = words.HvoArray[index]; m_selectedParserConnection.Parser.ScheduleOneWordformForUpdate(hvo, priority); } }
/// <summary> /// this will be called from the parser's thread; we need to marshal it to the client's thread /// so that it comes in as a normal event in the event handling loop of the client. /// </summary> /// <param name="parser"></param> /// <param name="task"></param> public void ParserUpdateHandler(ParserScheduler parser, TaskReport task) { CheckDisposed(); if(null == m_clientTaskReportHandler) return; lock(this) { //using Invoke () here would cause this thread to wait until the event was handled. ((Control)m_clientTaskReportHandler.Target).BeginInvoke(m_clientTaskReportHandler, new object[] {parser, task}); } //testing //((Control)m_clientTaskReportHandler.Target).Invoke(m_clientTaskReportHandler, new object[] {parser, task}); }
protected abstract void LoadParser(ref XmlDocument model, XmlDocument template, TaskReport task, ParserScheduler.NeedsUpdate eNeedsUpdate);
/// <summary> /// Initializes a new instance of the <see cref="ParserConnection"/> class. /// This will attempt to connect to an existing parser or start a new one if necessary. /// </summary> public ParserConnection(FdoCache cache, IdleQueue idleQueue) { m_activity = ""; m_scheduler = new ParserScheduler(cache, idleQueue, Path.Combine(FwDirectoryFinder.CodeDirectory, FwDirectoryFinder.ksFlexFolderName)); m_scheduler.ParserUpdateVerbose += ParserUpdateHandlerForPolling; }
private void SetDescriptionAndFxtFile(ParserScheduler.NeedsUpdate eNeedsUpdate, out string sDescription, out string sFxtFile) { const string ksFXTPath = @"Language Explorer\Configuration\Grammar\FXTs"; switch (eNeedsUpdate) { case ParserScheduler.NeedsUpdate.GrammarAndLexicon: sDescription = ParserCoreStrings.ksRetrievingGrammarAndLexicon; sFxtFile = Path.Combine(ksFXTPath,"M3Parser.fxt"); break; case ParserScheduler.NeedsUpdate.GrammarOnly: sDescription = ParserCoreStrings.ksRetrievingGrammar; sFxtFile = Path.Combine(ksFXTPath, "M3ParserGrammarOnly.fxt"); break; case ParserScheduler.NeedsUpdate.LexiconOnly: sDescription = ParserCoreStrings.ksRetrievingLexicon; sFxtFile = Path.Combine(ksFXTPath, "M3ParserLexiconOnly.fxt"); break; case ParserScheduler.NeedsUpdate.HaveChangedData: sDescription = ParserCoreStrings.ksUpdatingGrammarAndLexicon; sFxtFile = Path.Combine(ksFXTPath, "M3Parser.fxt"); break; default: throw new ApplicationException("M3ModelRetriever.RetrieveModel() invoked without reason"); } }
internal void MakeHCFiles(ref XmlDocument model, TaskReport parentTask, ParserScheduler.NeedsUpdate eNeedsUpdate) { using (m_topLevelTask = parentTask.AddSubTask(ParserCoreStrings.ksMakingXAmpleFiles)) { if (eNeedsUpdate == ParserScheduler.NeedsUpdate.GrammarAndLexicon || eNeedsUpdate == ParserScheduler.NeedsUpdate.LexiconOnly || eNeedsUpdate == ParserScheduler.NeedsUpdate.HaveChangedData) { DateTime startTime = DateTime.Now; TransformDomToFile("FxtM3ParserToHCInput.xsl", model, m_database + "HCInput.xml"); long ttlTicks = DateTime.Now.Ticks - startTime.Ticks; Trace.WriteLineIf(tracingSwitch.TraceInfo, "Lex XSLT took : " + ttlTicks.ToString()); } if (eNeedsUpdate == ParserScheduler.NeedsUpdate.GrammarAndLexicon || eNeedsUpdate == ParserScheduler.NeedsUpdate.GrammarOnly || eNeedsUpdate == ParserScheduler.NeedsUpdate.HaveChangedData) { DateTime startTime = DateTime.Now; TransformDomToFile("FxtM3ParserToToXAmpleGrammar.xsl", model, m_database + "gram.txt"); long ttlTicks = DateTime.Now.Ticks - startTime.Ticks; Trace.WriteLineIf(tracingSwitch.TraceInfo, "Grammar XSLTs took : " + ttlTicks.ToString()); // TODO: Putting this here is not necessarily efficient because it happens every time // the parser is run. It would be more efficient to run this only when the user // is trying a word. But we need the "model" to apply this transform an it is // available here, so we're doing this for now. startTime = DateTime.Now; string sName = m_database + "XAmpleWordGrammarDebugger.xsl"; TransformDomToFile("FxtM3ParserToXAmpleWordGrammarDebuggingXSLT.xsl", model, sName); ttlTicks = DateTime.Now.Ticks - startTime.Ticks; Trace.WriteLineIf(tracingSwitch.TraceInfo, "WordGrammarDebugger XSLT took : " + ttlTicks.ToString()); } } }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> private void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (m_isDisposed) return; m_clientTaskReportHandler = null; if (disposing) { // Dispose managed resources here. if (m_scheduler != null) { /* Don't know why it tries this, since the Dispose method in the scheduler calls Resume(). m_scheduler.AttemptToPause(); while (!m_scheduler.IsPaused) { // How long should we wait? // Or, should we put up a pacifier to let the user knwo we are trying to shut down the parser/ } */ // Remove event handlers. m_scheduler.ParserUpdateVerbose -= ParserUpdateHandlerForPolling; m_scheduler.ParserUpdateNormal -= ParserUpdateHandlerForPolling; if (m_localTaskReportHandler != null) { m_scheduler.ParserUpdateVerbose -= m_localTaskReportHandler; m_scheduler.ParserUpdateNormal -= m_localTaskReportHandler; } ParserFactory.ReleaseScheduler(m_scheduler); // ReleaseScheduler calls Dispose on m_scheduler. } } // Dispose unmanaged resources here, whether disposing is true or false. m_localTaskReportHandler = null; m_scheduler = null; m_currentError = null; m_activity = null; TraceResult = null; m_notificationMessage = null; m_isDisposed = true; }
protected override void LoadParser(ref XmlDocument model, XmlDocument template, TaskReport task, ParserScheduler.NeedsUpdate eNeedsUpdate) { try { M3ToHCTransformer transformer = new M3ToHCTransformer(m_database); transformer.MakeHCFiles(ref model, task, eNeedsUpdate); } catch (Exception error) { if (error.GetType() == Type.GetType("System.Threading.ThreadInterruptedException") || error.GetType() == Type.GetType("System.Threading.ThreadAbortException")) { throw error; } task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! throw new ApplicationException("Error while generating files for the Parser.", error); } try { string gramPath = Path.Combine(m_outputDirectory, m_database + "gram.txt"); m_patr.LoadGrammarFile(gramPath); string hcPath = Path.Combine(m_outputDirectory, m_database + "HCInput.xml"); m_loader.Load(hcPath); XmlNode delReappsNode = model.SelectSingleNode("/M3Dump/ParserParameters/HC/DelReapps"); if (delReappsNode != null) m_loader.CurrentMorpher.DelReapplications = Convert.ToInt32(delReappsNode.InnerText); } catch (Exception error) { if (error.GetType() == Type.GetType("System.Threading.ThreadInterruptedException") || error.GetType() == Type.GetType("System.Threading.ThreadAbortException")) { throw error; } ApplicationException e = new ApplicationException("Error while loading the Parser.", error); task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! throw e; } }
internal TimeStamp LoadGrammarAndLexicon(ParserScheduler.NeedsUpdate eNeedsUpdate) { CheckDisposed(); Trace.WriteLineIf(tracingSwitch.TraceInfo, "Worker.LoadGrammarAndLexicon: eNeedsUpdate = " + eNeedsUpdate); string sDescription = SetDescription(eNeedsUpdate); TaskReport task = new TaskReport(sDescription, m_taskUpdateHandler); // no longer need this pop-up; was only for debugging // task.NotificationMessage = "Loading Parser"; if (m_retriever == null) m_retriever = new M3ParserModelRetriever(m_database); TimeStamp stamp; using (task) { XmlDocument fxtResult; XmlDocument gafawsFxtResult; try { DateTime startTime = DateTime.Now; stamp = m_retriever.RetrieveModel(m_connection, m_LangProject, task, eNeedsUpdate); long ttlTicks = DateTime.Now.Ticks - startTime.Ticks; Trace.WriteLineIf(tracingSwitch.TraceInfo, "FXT took : " + ttlTicks.ToString()); fxtResult = m_retriever.ModelDom; gafawsFxtResult = m_retriever.TemplateDom; } catch (Exception error) { if (error.GetType() == Type.GetType("System.Threading.ThreadInterruptedException") || error.GetType() == Type.GetType("System.Threading.ThreadAbortException")) { throw error; } task.EncounteredError(null); // Don't want to show message box in addition to yellow crash box! throw new ApplicationException("Error while retrieving model for the Parser.", error); } LoadParser(ref fxtResult, gafawsFxtResult, task, eNeedsUpdate); } return stamp; }
/// <summary> /// </summary> /// <param name="parser"></param> /// <param name="task"></param> public void ParserUpdateHandlerForPolling(ParserScheduler parser, TaskReport task) { CheckDisposed(); //store this for clients which just want to poll us, instead of wiring up to the event m_activity = task.Description; m_currentError = task.CurrentError; if(task.NotificationMessage!=null && task.Phase != TaskReport.TaskPhase.finished )//keeps us from getting the notification at the end of the task. m_notificationMessage = task.NotificationMessage; //will have to do something more smart something when details is used for something else if(task.Details != null) TraceResult = task.Details; if (m_currentError!= null) System.Windows.Forms.MessageBox.Show(m_currentError.Message, ParserServiceStrings.ksParserProblem, MessageBoxButtons.OK,MessageBoxIcon.Exclamation); }
protected static string SetDescription(ParserScheduler.NeedsUpdate eNeedsUpdate) { string sDescription; switch (eNeedsUpdate) { case ParserScheduler.NeedsUpdate.GrammarAndLexicon: sDescription = ParserCoreStrings.ksLoadGrammarAndLexicon; break; case ParserScheduler.NeedsUpdate.GrammarOnly: sDescription = ParserCoreStrings.ksLoadGrammar; break; case ParserScheduler.NeedsUpdate.LexiconOnly: sDescription = ParserCoreStrings.ksLoadLexicon; break; case ParserScheduler.NeedsUpdate.HaveChangedData: sDescription = ParserCoreStrings.ksUpdatingGrammarAndLexicon; break; default: sDescription = ParserCoreStrings.ksNotDoingAnything; break; } return sDescription; }