Exemplo n.º 1
0
        public static bool CalculateReport(MetaFile meta, PrintOut printdriver, IWin32Window winowner)
        {
            CalcReportProgress nprogres = new CalcReportProgress();

            nprogres.driver       = printdriver;
            nprogres.meta         = meta;
            nprogres.ErrorMessage = "";
            nprogres.threadcalc   = new Thread(new ThreadStart(nprogres.Start));
            nprogres.threadcalc.Start();
            if (nprogres.threadcalc.Join(4000))
            {
                if (nprogres.ErrorMessage.Length > 0)
                {
                    throw new Exception(nprogres.ErrorMessage);
                }
                return(meta.Finished);
            }
            // Else create form and show it
            ReportProgressForm ndia = new ReportProgressForm();

            try
            {
                nprogres.ndia    = ndia;
                ndia.multithread = true;
                ndia.metafile    = meta;
                MetaFileWorkProgress workevent = new MetaFileWorkProgress(ndia.WorkProgress);
                meta.OnWorkProgress += workevent;
                try
                {
                    ndia.ShowDialog(winowner);
                }
                finally
                {
                    meta.OnWorkProgress -= workevent;
                }
            }
            finally
            {
                Monitor.Enter(nprogres.flag);
                try
                {
                    nprogres.ndia = null;
                    ndia.Dispose();
                }
                finally
                {
                    Monitor.Exit(nprogres.flag);
                }
            }
            if (!nprogres.threadcalc.Join(1000))
            {
                nprogres.threadcalc.Abort();
            }
            nprogres.threadcalc = null;
            if (nprogres.ErrorMessage.Length > 0)
            {
                throw new Exception(nprogres.ErrorMessage);
            }
            return(meta.Finished);
        }
Exemplo n.º 2
0
        public static void CalculateReport(MetaFile meta, PrintOut driver)
        {
            using (ReportProgressForm nform = new ReportProgressForm())
            {
                nform.intdriver      = driver;
                nform.intmeta        = meta;
                nform.timer1.Enabled = true;

                nform.ShowDialog();
            }
        }