private void PrimeExampleContinueWith() { var nextPrime = new Task <long>(() => LectureMath.NextPrime(1000000000)); nextPrime.ContinueWith(antecedent => { long result = antecedent.Result; this.taskResult.BeginInvoke(new Action(() => this.taskResult.Text += "Next Prime is " + result)); }); nextPrime.Start(); }
private void PrimeExample() { var nextPrime = Task.Run(() => LectureMath.NextPrime(1000000000)); var awaiter = nextPrime.GetAwaiter(); awaiter.OnCompleted(() => { long result = awaiter.GetResult(); this.taskResult.BeginInvoke(new Action(() => this.taskResult.Text += "Next Prime is " + result)); }); }