Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void m_oBackGroundWorker_DoWork(object sender, DoWorkEventArgs e)
- {
- int n = int.Parse(losowaniaBox.Text);
- int trafienie = 0;
- List<double> tempResults = new List<double>();
- Random r = new Random();
- for (int nCounter = 1; nCounter < n; nCounter += 1)
- {
- if (Math.Pow(r.NextDouble(), 2) + Math.Pow(r.NextDouble(), 2) <= 1)
- {
- trafienie++;
- }
- if(m_oBackgroundWorker.CancellationPending)
- {
- e.Cancel = true;
- break;
- }
- double aproksymacja = 4.0 * trafienie / n;
- double bezwzgledna = Math.Abs(Math.PI - aproksymacja);
- for (int j = 0; j <= n; j++)
- {
- tempResults.Add(trafienie);
- tempResults.Add(aproksymacja);
- tempResults.Add(bezwzgledna);
- }
- Thread.Sleep(1000);
- m_oBackgroundWorker.ReportProgress(nCounter, tempResults);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement