I have a program that constantly checks a specific folder in Outlook. The check occurs every 2 seconds. The program sometimes freezes up after Line 6 and before Line 9. If I go to the console screen and hit the Enter key the program will continue on. The problem might be because I'm constantly checking the Outlook folder. Is there something else that I can do instead of constantly checking? Or can I fix my code? But I don't see anything really wrong with it.
1. while (true)
2. {
3. Outlook.MAPIFolder oFolder = (Outlook.MAPIFolder)(oNS.Folders.Item(2);
4. Console.WriteLine (oFolder.Name.ToString()+" has this many mail "+oFolder.Items.Count);
5. int numMail = oFolder.Items.Count;
6. Console.writeln (numMail);
7. if (numMail > 0)
8. {
9. <do something>
10. }
11. Thread.Sleep(2000);
12. }
" ahhh computers, how they made our lives much simpler "
1. while (true)
2. {
3. Outlook.MAPIFolder oFolder = (Outlook.MAPIFolder)(oNS.Folders.Item(2);
4. Console.WriteLine (oFolder.Name.ToString()+" has this many mail "+oFolder.Items.Count);
5. int numMail = oFolder.Items.Count;
6. Console.writeln (numMail);
7. if (numMail > 0)
8. {
9. <do something>
10. }
11. Thread.Sleep(2000);
12. }
" ahhh computers, how they made our lives much simpler "