コード例 #1
0
ファイル: MainForm.cs プロジェクト: allaouiamine/RI-Project
 private void bList_Click(object sender, EventArgs e)
 {
     bList.Enabled = false;
     Statistics _statistics = new Statistics();
     _statistics.Notification += new Statistics.UpdateProgress(_statistics_Notification);
     _statistics.SetDataSource += new Statistics.SetListBoxDataSource(_statistics_SetDataSource);
     //_statistics.ShowStats += new Statistics.ShowStatistics(_statistics_Statistics);
     _statistics.GetFileList("http://www.emse.fr/~mbeig/ORI-2011/INEX-BASED-Wikipedia2009-COLLECTIONS/");
 }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: allaouiamine/RI-Project
        private void bProceed_Click(object sender, EventArgs e)
        {
            bProceed.Enabled = false;
            DateTime start = DateTime.Now;
            for (int i = 0; i < trackBar1.Value; i++)
            {
                Statistics _statistics = new Statistics();
                _statistics.Notification += new Statistics.UpdateProgress(_statistics_Notification);
                //_statistics.SetDataSource += new Statistics.SetListBoxDataSource(_statistics_SetDataSource);
                //_statistics.ShowStats += new Statistics.ShowStatistics(_statistics_Statistics);
                _statistics.Work(
                    (lbFiles.Items[i] is KeyValuePair<string, string>
                         ? (KeyValuePair<string, string>) lbFiles.Items[i]
                         : new KeyValuePair<string, string>()).Value);
            }

            int tasks = trackBar1.Value;

            Task f = Task.Factory.StartNew(() =>
                                               {
                                                   while (Statistics.FinishedNumber != tasks)
                                                   {
                                                       //Wait to complete a job.
                                                   }
                                               }).ContinueWith(_ =>
                                                                   {
                                                                       var time = (DateTime.Now - start).TotalSeconds;
                                                                       Console.WriteLine("Execution time: " + time);
                                                                       Console.WriteLine("Total amount of words: " + Statistics.GlobalStatistic.Count);
                                                                       Console.WriteLine("Total amount of documents: " + Statistics.DocumentsNumber);

                                                                       StreamWriter writer = new StreamWriter("stats.txt", true);
                                                                       writer.WriteLine(time.ToString() + "\t" +
                                                                                        Statistics.GlobalStatistic.Count +
                                                                                        "\t" +
                                                                                        Statistics.DocumentsNumber);
                                                                       writer.Close();

                                                                       if(MessageBox.Show("Would you like to print statistics?","Show statistics?",MessageBoxButtons.YesNo) == DialogResult.Yes)
                                                                        _statistics_Statistics(Statistics.GlobalStatistic);

                                                                       Statistics.GlobalStatistic.Clear();
                                                                       Statistics.FinishedNumber = 0;
                                                                       Statistics.DocumentsNumber = 0;
                                                                       bProceed.Enabled = true;

                                                                   });
        }