public void ProcessAllItems(string username, string password, int threadCount, Action <string, Exception> callback) { var formattedPassword = m_communicationProvider.GetFormattedPasswordAsAuthToken(password); ParallelLoopResult result = Parallel.ForEach(m_files, new ParallelOptions { MaxDegreeOfParallelism = threadCount }, model => ProcessFile(model, username, formattedPassword, callback)); }