/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="DummyParser"/> class. /// </summary> /// ----------------------------------------------------------------------------------- public ParserWorker(SqlConnection connection, string database, string LangProject, TaskUpdateEventHandler handler, string parserName, string parserVersion) { Debug.Assert(connection != null && connection.State == System.Data.ConnectionState.Open); m_LangProject = LangProject; m_database = database; m_taskUpdateHandler = handler; Trace.WriteLineIf(tracingSwitch.TraceInfo, "ParserWorker(): CurrentThreadId = " + Win32.GetCurrentThreadId().ToString()); // Don't create the XAmpleWrapper yet because we're still on the UI thread. If we // create it now, the apartment thread it uses will be the UI thread, which is not // what we want! //CreateXAmpleWrapper(); m_agentInfo.m_isHuman = false; m_agentInfo.m_name = parserName; m_agentInfo.m_version = parserVersion; m_connection = connection; m_parserFiler = new ParseFiler(m_connection, AnalyzingAgentId); try { SqlCommand command = m_connection.CreateCommand(); command.CommandText = "select top 1 Dst\n" + "from LangProject_CurVernWss\n" + "order by Ord\n"; m_vernacularWS = (int)command.ExecuteScalar(); } catch (Exception error) { throw new ApplicationException("Error while getting the default vernacular writing system.", error); } m_iNumberOfWordForms = GetWfiSize(); m_ticksParser = 0L; m_ticksFiler = 0L; }
/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="TaskReport"/> class. /// </summary> /// ----------------------------------------------------------------------------------- public TaskReport(string description, TaskUpdateEventHandler eventReceiver) :this(description, (TaskReport)null) { if (eventReceiver!= null) m_taskUpdateEvent += eventReceiver; InformListeners (TaskPhase.started);//don't move this down to the other constructor }
/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="TaskReport"/> class. /// </summary> /// ----------------------------------------------------------------------------------- public TaskReport(string description, TaskUpdateEventHandler eventReceiver) : this(description, (TaskReport)null) { if (eventReceiver != null) { m_taskUpdateEvent += eventReceiver; } InformListeners(TaskPhase.started); //don't move this down to the other constructor }
/// <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; } if (disposing) { Trace.WriteLineIf(tracingSwitch.TraceInfo, "Total number of wordforms = " + m_iNumberOfWordForms.ToString()); Trace.WriteLineIf(tracingSwitch.TraceInfo, "Total time for XAmple parser = " + m_ticksParser.ToString()); if (m_iNumberOfWordForms != 0) { long lAvg = m_ticksParser / m_iNumberOfWordForms; Trace.WriteLineIf(tracingSwitch.TraceInfo, "Average time for XAmple parser = " + lAvg.ToString()); } Trace.WriteLineIf(tracingSwitch.TraceInfo, "Total time for parser filer = " + m_ticksFiler); if (m_iNumberOfWordForms != 0) { long lAvg = m_ticksFiler / m_iNumberOfWordForms; Trace.WriteLineIf(tracingSwitch.TraceInfo, "Average time for parser filer = " + lAvg.ToString()); } // Dispose managed resources here. if (m_parserFiler != null) { m_parserFiler.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_taskUpdateHandler = null; m_parserFiler = null; m_connection = null; // Client needs to close and Dispose the connection, since it gave it to us. CleanupParser(); m_LangProject = null; m_database = null; m_isDisposed = true; }
/// <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; if (disposing) { Trace.WriteLineIf(tracingSwitch.TraceInfo, "Total number of wordforms = " + m_iNumberOfWordForms.ToString()); Trace.WriteLineIf(tracingSwitch.TraceInfo, "Total time for XAmple parser = " + m_ticksParser.ToString()); if (m_iNumberOfWordForms != 0) { long lAvg = m_ticksParser/m_iNumberOfWordForms; Trace.WriteLineIf(tracingSwitch.TraceInfo, "Average time for XAmple parser = " + lAvg.ToString()); } Trace.WriteLineIf(tracingSwitch.TraceInfo, "Total time for parser filer = " + m_ticksFiler); if (m_iNumberOfWordForms != 0) { long lAvg = m_ticksFiler/m_iNumberOfWordForms; Trace.WriteLineIf(tracingSwitch.TraceInfo, "Average time for parser filer = " + lAvg.ToString()); } // Dispose managed resources here. if (m_parserFiler != null) m_parserFiler.Dispose(); } // Dispose unmanaged resources here, whether disposing is true or false. m_taskUpdateHandler = null; m_parserFiler = null; m_connection = null; // Client needs to close and Dispose the connection, since it gave it to us. CleanupParser(); m_LangProject = null; m_database = null; m_isDisposed = true; }
/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="DummyParser"/> class. /// </summary> /// ----------------------------------------------------------------------------------- public DummyParser(SqlConnection connection, string database, string LangProject, TaskUpdateEventHandler handler) : base(connection, database, LangProject, handler) { }
public XAmpleParserWorker(SqlConnection connection, string database, string LangProject, TaskUpdateEventHandler handler) : base(connection, database, LangProject, handler, "M3Parser", "Normal") { }
public HCParserWorker(SqlConnection connection, string database, string LangProject, TaskUpdateEventHandler handler) : base(connection, database, LangProject, handler, "HCParser", "Normal") { m_outputDirectory = Path.GetTempPath(); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="DummyParser"/> class. /// </summary> /// ----------------------------------------------------------------------------------- public DummyParser(SqlConnection connection, string database, string LangProject, TaskUpdateEventHandler handler) :base(connection, database, LangProject, handler) { }