public void ResolveAllUnresolved(IOutputWriter cache) { var padlock = new object(); var numFinished = 0; for (int i = 0; i < cache.Files.Count; i++) { var file = cache.Files[i]; ThreadPool .QueueUserWorkItem((evnt) => { var partials = new List <PartialType>(); getPartials(cache.Classes, file, partials); getPartials(cache.Interfaces, file, partials); getPartials(cache.Structs, file, partials); getPartials(cache.Enums, file, partials); getPartials(cache.Fields, file, partials); getPartials(cache.Methods, file, partials); getPartials(cache.Variables, file, partials); _cache.ResolveMatchingType(partials.ToArray()); lock (padlock) { numFinished++; } }); } while (numFinished != cache.Files.Count) { Thread.Sleep(100); } }