コード例 #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);
                }
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: rygel/M43RawAnalyzer
        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);
                }
            }
        }