Hi, can someone help me, I don't know what to do to stop my program from freezing when there are no more results. Here is the snippet of code
while (codeCollection.Count < numberOfCodes)
{
String currentCode = generateCode();
CodeVerification cv = new CodeVerification();
if ((cv.checkWords(currentCode) == -1) && (cv.checkSameChars(currentCode) == -1) && (cv.checkCodeMix(currentCode, percentLet, percentNum) == -1))
{
if (codeCollection.Add(currentCode))
{
filePrint.WriteLine(currentCode);
}
}
}
|
This is part of a program to generate random numbers (codes) and when there are more codes requested than are possible (hashset doesn't take duplicates) the program freezes, I tried to put in a try catch block but it didn't work, any suggestions??
Thanks
krishna vPosted Sep 11, 2010, 9:45 PM
If you are running multilple threads.. may be thread synchronization issues. Check the memory usage of the app. it is growing then may be coz of memeory leaks.. try to look for un-managed objects.
may be unhandled exceptions causing some issue.. to check any of the exceptions thrown in this scenario from visual studio enable break on exceptions.. may be it will give a clue.
Difficult to guess the exact reason.. may be a profilers can give u some clues.
Sam HobbsPosted Sep 10, 2010, 12:20 PM
Mahesh ChandPosted Sep 9, 2010, 12:51 PM
Hope it helps!