// // Private methods // #region Private methods // Find password private void FindPassword() { // File must be existent if (!File.Exists(mFileName)) { mPasswordRes.TrySetException(new ZipFileNotExistentException()); } // File must be protected by password else if (!mPasswordChecker.IsPasswordProtected()) { mPasswordRes.TrySetException(new ZipFileNotPasswordProtectedException()); } // Continue until a task founds the password // If an exception has been set, completed will be true and the loop will not be executed while (!mPasswordRes.Task.IsCompleted) { // Get next password string curr_pwd = mPasswordQueue.Take(); // Try to log (just discard the message if not added, there is no reason to block) mLogMessageQueue.TryAdd(new LogMessage(String.Format("Thread {0} - Trying password: {1}", mIndex, curr_pwd), mIndex)); // Check password bool found = mPasswordChecker.TryPassword(curr_pwd); // Set password result if found if (found) { mPasswordRes.SetResult(curr_pwd); } } // Final print if (!mPasswordChecker.PasswordFound) { mLogMessageQueue.Add(new LogMessage(String.Format("Thread {0} - Exiting...", mIndex), mIndex, true)); } else { mLogMessageQueue.Add(new LogMessage(String.Format("Thread {0} - Found password: {1}, exiting...", mIndex, mPasswordChecker.Password), mIndex, true)); } }