private void btnAnalysisWS_Click(object sender, EventArgs e) { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { Task <LinkedList <FileInfo> > t = Task <LinkedList <FileInfo> > .Run(() => WorkSpace.Analysis2(folderBrowserDialog1.SelectedPath)); try { t.Wait(); if (t.IsCompleted) { LinkedList <FileInfo> _finallist = t.Result; MessageBox.Show("Analysis completed successfully!!"); } } catch (AggregateException aex) { // Assume we know what's going on with this particular exception. // Rethrow anything else. AggregateException.Handle provides // another way to express this. See later example. foreach (Exception ex in aex.InnerExceptions) { // log the exceptions throw ex; } } } }