Example #1
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            BackgroundWorker worker = sender as BackgroundWorker;

            RW2Parser rw2Parser = new RW2Parser();

            string[] localFiles  = (string[])e.Argument;
            double   currentFile = 0;

            foreach (string filename in localFiles)
            {
                if ((worker.CancellationPending == true))
                {
                    e.Cancel = true;
                    break;
                }
                else
                {
                    currentFile++;
                    // Perform a time consuming operation and report progress.
                    rw2Parser.Parse2(filename);
                    double prog     = (currentFile / localFiles.Length) * 100;
                    int    progress = (int)Math.Truncate(prog);
                    worker.ReportProgress(progress);
                }
            }
        }
Example #2
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            BackgroundWorker worker = sender as BackgroundWorker;

            RW2Parser rw2Parser = new RW2Parser();

            string[] localFiles = (string[])e.Argument;
            double currentFile = 0;

            foreach (string filename in localFiles)
            {
                if ((worker.CancellationPending == true))
                {
                    e.Cancel = true;
                    break;
                }
                else
                {
                    currentFile++;
                    // Perform a time consuming operation and report progress.
                    rw2Parser.Parse2(filename);
                    double prog = (currentFile / localFiles.Length) * 100;
                    int progress = (int)Math.Truncate(prog);
                    worker.ReportProgress(progress);
                }
            }
        }