0

So I have been doing some research on how to programmatically schedule a task, and as of now I haven't really found anything that useful or informative on it. It could be because I am searching for the wrong thing, but thats why I am hoping you guys can help me out.

Here is what I have :

I have a C# Windows Forms Application created in Visual Studio 2013... ideally what I had in mind was to create a button that opens up a form and allows the user to schedule a time and frequency of a task and then set it (if that task already exists, update it).

So I was looking at the ITaskScheduler, but I am really clueless as to how I can use it and implement it. Not sure what assemblies I need to import etc... Was looking at this Link on pinvoke

However, if that cannot be done I am open for any suggestions. I am experienced in C/C++, and I know I have seen a few methods for C++ but nothing that looked very promising.

Here is the alternative I was thinking :

Simply just create a different program and then just schedule the .exe to run when I want.

  • As of now I am leaning heavily towards this method, but I am relatively new to programming in Visual Studio. However, I am an experienced programmer.
  • My question on this is... what would be the preferred method of creating this program? Would it be creating a Windows Form Application or a Console Application or just a plain empty project with a Main() method

So if you guys can shed some light on this subject for me that would be greatly appreciated.

JaneGoodall
  • 1,478
  • 2
  • 15
  • 22
Adjit
  • 10,134
  • 12
  • 53
  • 98
  • possible duplicate of [Creating Scheduled Tasks](http://stackoverflow.com/questions/7394806/creating-scheduled-tasks) – Ken White Apr 04 '14 at 22:53

2 Answers2

0

Personal opinion:

If the tasks are few and not that often, I would use a Windows Scheduled Task. To keep things compact, the task could run the same .EXE that created the task, but with different parameters.

If there are going to be lots of little tasks running throughout the day which need to be tracked, logged, etc, I would probably create a Windows Service to run them, and a seperate front end for user interaction.

WhoIsRich
  • 4,053
  • 1
  • 33
  • 19
0

The easiest way would seriously be to use a Cygwin cronjob. First, install Cygwin with cygrunsrv. Then:

sudo crontab -e
*/5 * * * *  /path/to/your/shell/script.sh

This would run every five minutes but you can tinker with the schedule as you see fit.

The crontab file is just a text file so users should be able to edit it through a Visual Studio application.

Community
  • 1
  • 1
JaneGoodall
  • 1,478
  • 2
  • 15
  • 22