Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

Problems Debugging a C# Windows command line with a timer event...

$
0
0

I have written a C# application that monitors an email account I would like some advise on how to trouble shoot more effectively.  

Each 5 minutes, the application checks the account for new mail, downloads those emails, saves out attachments, converts as needed, parses the results into MySQL tables for later use, writes various "data exceptions" to a table and log and matains a general run log file.  The main form has a timer to control the 5 minute cycle.  Since the time of processing can vary from seconds (no new mail) to 20 minutes or so (large number of emails to process), the timer event code disables the timer at the start of processing and reinables when compete.  The programs "main" has a loop that keeps the program up and allows a user to quit the application or fire off a new email fetch run NOW.

Since it is new, and development is on-going, there are bugs. ;)

If the app is run in debugging mode and the offending code raises an exception, the debugger kicks in an one can step through the code and see what gives.  But is seems there are situations where no exception is raised but the lack of console writes shows the email process did not complete (and of coure, the timer is still disabled.)  I have a text propeller in the main loop and it is still spinning, so the app is not generally locked up, but perhaps the code called by the timer event is - or - it just errored and exited.

If I am running the app from the EXE, some times I find it in the state above and sometimes it has exited to the console without fanfair.

This reduces the debugging to enabling Console.WriteLine statements declaring "I am at this point!" or "We are at that place!" - a time consuming effort in this application because there are many paths through the code - 3,000+ lines and more to come.

I have thought of removing the timer and just putting a SitNSpin for 300,000 ms at the bottom of the loop, but that seems a bit 1980's or something. 

Any additional thoughts or ideas much appriciated!

Clay Goss


Viewing all articles
Browse latest Browse all 1764

Trending Articles