Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

vb.net - Setting up a scheduled task in .Net

I've read a few posts here on StackOverflow about task scheduling, but I'm not sure that I get it right. I'm coding (in VB.Net) a backup application, that I'd like to add as a scheduled task (in fact, I'd just like to let the user decide to run it every day at, for example, 3 AM).

I've read posts suggesting to use a windows service for this, but it sounds a bit to much for something as simple as periodically running a task, isn't it?

Could you please advise me on how to simply set a scheduled task in VB.Net? I'm trying to keep my code as lightweight as possible.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The best thing is to not write a scheduler, but use the built-in Windows scheduler to run your code.

More info:

http://support.microsoft.com/kb/308569

Note: if you schedule a task to run under an account other than your own, the application may not have access to network drives or some other resources. In other words, there may be some security challenges to work through, particularly for something like a backup app.

If this is just a personal app for backup, my recommendation would be to use XCOPY from a batch file rather than re-inventing the wheel.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...