Ejemplo n.º 1
0
 public void ProgressNotification(int iPercentDone)
 {
     if (m_Form.InvokeRequired)
     {
         m_Form.BeginInvoke(m_Form.m_DelegateUpdateProgressbar,
                            new Object[] { iPercentDone });
     }
 }
Ejemplo n.º 2
0
        public void ThreadProc()
        {
            using (NamedPipeServerStream pipeServer =
                       new NamedPipeServerStream("ZalConversionLog", PipeDirection.In))
            {
                using (StreamReader srInStream = new StreamReader(pipeServer, Encoding.Unicode))
                {
                    using (StreamWriter swLogFile = new StreamWriter(m_sPath, true, Encoding.Unicode))
                    {
                        try
                        {
                            while (!bTerminate())
                            {
                                pipeServer.WaitForConnection();
                                string sLine        = srInStream.ReadToEnd();
                                string sNoLogPrefix = ("*** NO_LOG *** ");
                                if (sLine.StartsWith(sNoLogPrefix))
                                {
                                    sLine = sLine.Substring(sNoLogPrefix.Length);
                                }
                                else
                                {
                                    swLogFile.WriteLine(sLine);
                                    swLogFile.Flush();
                                }

                                if (m_Form.InvokeRequired)
                                {
                                    m_Form.BeginInvoke(m_Form.m_DelegateAddString,
                                                       new Object[] { sLine });
                                }
                                pipeServer.Disconnect();
                            }
                        }
                        catch (Exception ex)
                        {
                            string sMsg = "I/O error in ListenerThread/StreamReader: ";
                            sMsg += ex.Message;
                            MessageBox.Show(sMsg,
                                            "Zal Error",
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Exclamation);
                            return;
                        }
                    }
                } //  using (StreamReader sr...)
            }     //  using (NamedPipeServerStream pipeServer ...)
        }         //  ThreadProc()
Ejemplo n.º 3
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()