private async void FindPrimeNumbersBtnParallelTask_Click(object sender, RoutedEventArgs e) { if (_toNumber < _fromNumber) { ShowMessageBox("To should be larger or equal to the from."); } if (_toNumber < _fromNumber) { ShowMessageBox("To should be larger or equal to the from."); } WriteToConsole($"Running in Parallel Data, finding primenumbers between {_fromNumber} - {_toNumber}"); var list = await Task.Run(() => _primeFinder.GetPrimesParallelData(_fromNumber, _toNumber)); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("Prime numbers: "); foreach (long l in list) { stringBuilder.Append(l + ","); } WriteToConsole(stringBuilder.ToString()); WriteToConsole("Task took " + PrimeGenerator.stopwatch.Elapsed); }