private void hashing(int threadID, string startWord, int lenght, IDataSaver saver, IHash hash) { logger.log(DateTime.Now + "::Thread with ID: " + threadID + " started"); WordGenerator wGen = new WordGenerator(startWord); for (int i = 0; i < lenght; i++) { wGen.Next(); saver.PushData(wGen.GetCurrentWord(), hash.Hash(wGen.GetCurrentWord())); } saver.Finish(); isDone[threadID] = true; logger.log(DateTime.Now + "::Thread with ID: " + threadID + " completed"); }
private void manage() { while (isProgramRunning) { for (int i = 0; i < workers.Length; i++) { if (isDone[i] == true) { //new job and start currentFileNr++; saver[i] = new DataSaverLocalHDD(logger, dir[currentDriveGiven], currentFileNr + ".txt", fileUnFinishedTag); driveCounter(); workers[i] = new Thread(() => hashing(i, currentWord, nrOfGroupedHashes, saver[i], hash)); workers[i].Start(); isDone[i] = false; logger.log(DateTime.Now + "::Finding next job"); WordGenerator w = new WordGenerator(currentWord); //create new currentword with Wordjumper for (int j = 0; j < nrOfGroupedHashes; j++) //temp cuz wordjumper no ready { w.Next(); } currentWord = w.GetCurrentWord(); logger.log(DateTime.Now + "::Next job found"); } } Thread.Sleep(1); } }