Exemplo n.º 1
0
        void mJobMonitor_JobCompleted(object sender, JobEventArgs e)
        {
            mRunning = false;

            // Thread safe (it runs on UI thread):
            this.Invoke((MethodInvoker) delegate
            {
                try
                {
                    zLogTxb.AppendText(e.Line);

                    // Update status bar:
                    zTiming_ToolStripLbl.Text = String.Empty;

                    // Update progress bar:
                    mStatusBarProgressBar.Value = 0;

                    btnConvert.Enabled = true;
                    btnClose.Enabled   = true;


                    // Rename file:

                    /*if (File.Exists(this.mTempOutputName))
                     * {
                     *  FileStream zFS = Program.WaitForFile(this.mTempOutputName);
                     *  zFS.Close();
                     *  File.Move(this.mTempOutputName, Properties.Settings.Default.FormSettings_WorkingPath + Path.DirectorySeparatorChar +
                     *      Path.GetFileNameWithoutExtension(txbOutputTDF.Text) + ".tdf");
                     * }*/
                }
                catch (Exception)
                {
                }
            });
        }
        void mJobMonitor_JobCompleted(object sender, JobEventArgs e)
        {
            // Thread safe (it runs on UI thread):
            this.Invoke((MethodInvoker) delegate
            {
                try
                {
                    zLogTxb.AppendText(e.Line);

                    // Update status bar:
                    zTiming_ToolStripLbl.Text = String.Empty;

                    // Update progress bar:
                    mStatusBarProgressBar.Value = 0;

                    // Rename file:
                    if (File.Exists(this.mTempOutputName))
                    {
                        FileStream zFS = Program.WaitForFile(this.mTempOutputName);
                        zFS.Close();
                    }


                    /* Start the new job: */
                    if (mPreProcessOnGoing)
                    {
                        BackgroundWorker aBgdWrk = new BackgroundWorker();

                        aBgdWrk.DoWork += new DoWorkEventHandler(this.runRemotePhaseRetrieval);
                        aBgdWrk.RunWorkerAsync();


                        this.lblPhaseRetrieval.Enabled = true;
                        this.lblPreProcessing.Enabled  = false;
                        this.lblReconstruction.Enabled = false;

                        // Delete file:

                        /*string zFile = this.mInputTDF.Remove(this.mInputTDF.Length - 4) + "_corr_00.txt"; // It should be "*_00.txt"
                         * if (File.Exists(zFile))
                         * {
                         *  FileStream zFS = Program.WaitForFile(zFile);
                         *  zFS.Close();
                         * }
                         * File.Delete(zFile);*/
                    }
                    else if (mPhaseRetrievalOnGoing)
                    {
                        BackgroundWorker aBgdWrk = new BackgroundWorker();

                        aBgdWrk.DoWork += new DoWorkEventHandler(this.runRemoteReconstruction);
                        aBgdWrk.RunWorkerAsync();

                        this.lblPreProcessing.Enabled  = false;
                        this.lblPhaseRetrieval.Enabled = false;
                        this.lblReconstruction.Enabled = true;

                        // Delete file:

                        /*string zFile = this.mInputTDF.Remove(this.mInputTDF.Length - 4) + "_phrt_00.txt"; // It should be "*_00.txt"
                         * if (File.Exists(zFile))
                         * {
                         *  FileStream zFS = Program.WaitForFile(zFile);
                         *  zFS.Close();
                         * }
                         * File.Delete(zFile);*/
                    }
                    else if (mReconstructionOnGoing)
                    {
                        mReconstructionOnGoing = false;

                        this.lblPreProcessing.Enabled  = true;
                        this.lblPhaseRetrieval.Enabled = true;
                        this.lblReconstruction.Enabled = true;

                        // Update status bar:
                        zTiming_ToolStripLbl.Text = String.Empty;

                        // Update progress bar:
                        mStatusBarProgressBar.Value = 0;

                        btnRun.Enabled   = true;
                        btnClose.Enabled = true;

                        // Delete file:
                        string zFile = this.mInputTDF.Remove(this.mInputTDF.Length - 4) + "_corr.tdf";
                        if (File.Exists(zFile))
                        {
                            FileStream zFS = Program.WaitForFile(zFile);
                            zFS.Close();
                        }
                        File.Delete(zFile);

                        // Delete file:
                        zFile = this.mInputTDF.Remove(this.mInputTDF.Length - 4) + "_corr_phrt.tdf";
                        if (File.Exists(zFile))
                        {
                            FileStream zFS = Program.WaitForFile(zFile);
                            zFS.Close();
                        }
                        File.Delete(zFile);

                        // Delete file:

                        /*zFile = this.mInputTDF.Remove(this.mInputTDF.Length - 4) + "_recon_00.txt"; // It should be "*_00.txt"
                         * if (File.Exists(zFile))
                         * {
                         *  FileStream zFS = Program.WaitForFile(zFile);
                         *  zFS.Close();
                         * }
                         * File.Delete(zFile);*/
                    }
                }
                catch (Exception)
                {
                    // Update status bar:
                    zTiming_ToolStripLbl.Text = String.Empty;

                    // Update progress bar:
                    mStatusBarProgressBar.Value = 0;

                    btnRun.Enabled   = true;
                    btnClose.Enabled = true;
                }
                finally
                {
                }
            });
        }