Task<SolutionInfo> CreateSolutionInfo (MonoDevelop.Projects.Solution solution, CancellationToken token) { return Task.Run (async delegate { var projects = new ConcurrentBag<ProjectInfo> (); var mdProjects = solution.GetAllProjects (); projectionList.Clear (); solutionData = new SolutionData (); List<Task> allTasks = new List<Task> (); foreach (var proj in mdProjects) { if (token.IsCancellationRequested) return null; var netProj = proj as MonoDevelop.Projects.DotNetProject; if (netProj != null && !netProj.SupportsRoslyn) continue; var tp = LoadProject (proj, token).ContinueWith (t => { if (!t.IsCanceled) projects.Add (t.Result); }); allTasks.Add (tp); } await Task.WhenAll (allTasks.ToArray ()); if (token.IsCancellationRequested) return null; var modifiedWhileLoading = modifiedProjects = new List<MonoDevelop.Projects.DotNetProject> (); var solutionInfo = SolutionInfo.Create (GetSolutionId (solution), VersionStamp.Create (), solution.FileName, projects); foreach (var project in modifiedWhileLoading) { if (solution.ContainsItem (project)) { return await CreateSolutionInfo (solution, token).ConfigureAwait (false); } } lock (addLock) { if (!added) { added = true; OnSolutionAdded (solutionInfo); } } return solutionInfo; }); }