示例#1
0
        public void ThreadProc()
        {
            ZalConversionLib.ZalSourceReader reader;
            try
            {
                reader = new ZalConversionLib.ZalSourceReader();
                EventSink sink = new EventSink(m_Form);
                reader.ProgressNotification += sink.ProgressNotification;
                reader.ShowCurrentWord      += sink.ShowCurrentWord;
                reader.StatusCheck          += sink.StatusCheck;
                switch (m_Form.iSelectedTabIndex)
                {
                case 0:
                    reader.ConvertSourceFile(m_Form.sSourcePath,
                                             m_Form.sDbPath,
                                             m_Form.sUnprocessedPath,
                                             m_Form.iStopAfter,
                                             m_Form.iEndings);
                    break;

//                    case 1:
//                        reader.PreprocessSourceFile (m_Form.sSourcePath,
//                                                     Path.GetDirectoryName (m_Form.sSourcePath));
//                        break;
                case 1:
                    reader.SearchSourceFile(m_Form.sSourcePath,
                                            m_Form.sSearchString,
                                            (int)m_Form.iRegexSearch);
                    break;

                default:
                    string sMsg = "Illegal tab index";
                    MessageBox.Show(sMsg, "Zal Error", MessageBoxButtons.OK);
                    break;
                }
            }
            catch (Exception ex)
            {
                string sMsg = "Error in WorkerThread: ";
//                ZalConversionLib.ZalError err = new ZalConversionLib.ZalError();
                sMsg += ex.Message;
                sMsg += "\r\n";
//                sMsg += err.LastError;
                MessageBox.Show(sMsg, "Zal Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (m_Form.InvokeRequired)
            {
                m_Form.BeginInvoke(m_Form.m_DelegateSignalCompletion);
            }

            ConverterForm.sm_Event.WaitOne();

            if (m_Form.m_bSaveTempData)
            {
                if (m_Form.m_iSelectedTab != 1)
                {
                    string sMsg = "Error in WorkerThread: Unexpected tab value.";
                    MessageBox.Show(sMsg, "Zal Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                reader.SaveOutput(m_Form.sOutPath);
            }
        } //  ThreadProc()
示例#2
0
        public void ThreadProc()
        {
            ZalConversionLib.ZalSourceReader reader;
            try
            {
                reader = new ZalConversionLib.ZalSourceReader();
                EventSink sink = new EventSink (m_Form);
                reader.ProgressNotification += sink.ProgressNotification;
                reader.ShowCurrentWord += sink.ShowCurrentWord;
                reader.StatusCheck += sink.StatusCheck;
                switch (m_Form.iSelectedTabIndex)
                {
                    case 0:
                        reader.ConvertSourceFile (m_Form.sSourcePath,
                                                  m_Form.sDbPath,
                                                  m_Form.sUnprocessedPath,
                                                  m_Form.iStopAfter,
                                                  m_Form.iEndings);
                        break;
            //                    case 1:
            //                        reader.PreprocessSourceFile (m_Form.sSourcePath,
            //                                                     Path.GetDirectoryName (m_Form.sSourcePath));
            //                        break;
                    case 1:
                        reader.SearchSourceFile (m_Form.sSourcePath,
                                                 m_Form.sSearchString,
                                                 (int)m_Form.iRegexSearch);
                        break;
                    default:
                        string sMsg = "Illegal tab index";
                        MessageBox.Show (sMsg, "Zal Error", MessageBoxButtons.OK);
                        break;
                }
            }
            catch (Exception ex)
            {
                string sMsg = "Error in WorkerThread: ";
            //                ZalConversionLib.ZalError err = new ZalConversionLib.ZalError();
                sMsg += ex.Message;
                sMsg += "\r\n";
            //                sMsg += err.LastError;
                MessageBox.Show (sMsg, "Zal Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (m_Form.InvokeRequired)
            {
                m_Form.BeginInvoke (m_Form.m_DelegateSignalCompletion);
            }

            ConverterForm.sm_Event.WaitOne();

            if (m_Form.m_bSaveTempData)
            {
                if (m_Form.m_iSelectedTab != 1)
                {
                    string sMsg = "Error in WorkerThread: Unexpected tab value.";
                    MessageBox.Show (sMsg, "Zal Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                reader.SaveOutput (m_Form.sOutPath);
            }
        }