Example #1
0
        private void ProcessDocumentsWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            var noOfItems = currentWorkObjects.Where(x => x.ready).Count();
            if (noOfItems > 0)
            {
                //Start processing of all workobjects.
                log4.Info("Document processing initiated. Now trying to process each document.");
                foreach (BO.WorkObject wo in currentWorkObjects)
                {
                    Task.Run(() => wo.Process());
                }

                //Wait for all documents to finish.
                log4.Info("Waiting for all documentprocessing to finish...");
                bool finished = false;
                while (!finished)
                {
                    var doneProcessing = currentWorkObjects.Where(x => x.finished || x.error).Count();
                    var total = currentWorkObjects.Count();
                    if (doneProcessing == total)
                        finished = true;

                    double progress = ((double)doneProcessing / total) * 100;
                    ProcessDocumentsWorker.ReportProgress(Convert.ToInt32(progress));
                    Thread.Sleep(100);
                }
            }

            else
            {
                log4.Info("There are no documents to be processed.");
            }
        }
Example #2
0
        public void ProcessDocuments()
        {
            bGetDocumentsDocuments.Enabled = false;
            bProcessDocuments.Enabled = false;
            btnSearchMore.Enabled = false;

            progressBar1.Minimum = 0;
            progressBar1.Maximum = 100;
            progressBar1.Value = 0;
            ProcessDocumentsWorker.RunWorkerAsync();
        }