开发者

Creating a long running, nightly task in .NET 3.5 for use on Windows Server 2008

I have a long running, compute and disk intensive task that needs to run nightly on Window Server 2008; my Framework of choice is .NET 3.5 sp1. There's a chance this task c开发者_JAVA百科ould fail too for any number of reasons (i.e. lack of disk space) and I'd like to make sure errors are handled & reported reasonably. Also, this task would require permission to do things like create a database connection and read/write to the file system. What options are available for getting things like this done?

Edit: My question is more about whether to use windows schedule or some other mechanism to kick off the process.


Create a Console Application. Inside the main() method, put a try-catch, and use SmtpClient to send notifications about unhandled exceptions. Compile it and add an entry to run it using the Scheduled Task applet.


This sounds like it's just a standard console application that needs to run on a set scheduled (Windows Scheduled Tasks) and needs simple logging/reporting and communication capabilities and probably some linq2sql for db crud operations.

Frankly, at this point, it sounds like your options are wide open.


Two words ... exception handling

One other word ... logging

In addition to all the other very sound advice offered by the others here, if this is to be a long running process to run unattended, I would pay extra attention to how you handle exceptions and how you log/report them so that you know if something went wrong and have enough information to correct the issue.


Do you have more specific questions? All of this is totally doable. You can catch and log exceptions in a log file, and mail those results using SMTP. You can also make connections to a database which is very simple. Is there one single thing that you are having problems with that we could help?

You can use the windows scheduler to set this app up as say a job to run at a specific time or duration, etc.


Code it.... What is the question ? Create a good solid code that handles everything and you'll have your task. you can make a service out of it, and ask windows to restart if fails, or just wrap it in an infinate loop with try / catch all but take care of things that if not fixed won't worth continue....

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜