Beispiel #1
0
        public static async Task <double> calcPiAsync()
        {
            Task <double> t = new Task <double>(() =>
            {
                return(Prakt4.ParallelPi_Tasks());
            });

            t.Start();
            double result = await t;

            return(result);
        }
Beispiel #2
0
        // calc pi
        private async void button2_Click(object sender, EventArgs e)
        {
            progressBar1.Value = 0;
            var           sw = Stopwatch.StartNew();
            Task <double> t  = new Task <double>(() =>
            {
                return(Prakt4.ParallelPi_Tasks());
            });

            t.Start();
            double result = await t;

            sw.Stop();
            pi_calc       = result;
            textBox2.Text = result.ToString();
            label2.Text   = sw.ElapsedMilliseconds.ToString() + " ms";

            progressBar1.Value = 100;
        }