Schedulle a task for some days of the week
-
My need is to schedulle to run a C# application once a day for some days of the week And I provide an UI to set those days So I was trying to find out if the best way is to make a service to do that or to programaticaly try to make a new Windows task to run the app as an exe Thanks for your help / suggestion Olivier
-
My need is to schedulle to run a C# application once a day for some days of the week And I provide an UI to set those days So I was trying to find out if the best way is to make a service to do that or to programaticaly try to make a new Windows task to run the app as an exe Thanks for your help / suggestion Olivier
-
My need is to schedulle to run a C# application once a day for some days of the week And I provide an UI to set those days So I was trying to find out if the best way is to make a service to do that or to programaticaly try to make a new Windows task to run the app as an exe Thanks for your help / suggestion Olivier
you could tell Windows to run it once a day, then in your code skip the days that you don't want any action taken. day selection information could be kept in a settings file, a separate file, the registry, whatever, which some app could display and modify through a GUI. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
you could tell Windows to run it once a day, then in your code skip the days that you don't want any action taken. day selection information could be kept in a settings file, a separate file, the registry, whatever, which some app could display and modify through a GUI. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
you could tell Windows to run it once a day, then in your code skip the days that you don't want any action taken. day selection information could be kept in a settings file, a separate file, the registry, whatever, which some app could display and modify through a GUI. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Thank you Luc Yes I know that link but I do not feel confident with that solution 1- I can't compile it because the post compile event wants to run mt.exe and I don't know why ? 2- As I can see it uses an uggly old fashion dos interface 3- At the first sight I thougt that the goal for that app was to create or edit Windows .job files and let Windows scheduller do the job. If so I do not understand why it needs 7 files of about 100k of source code to do that ? I'm afraid that this is just another scheduller ! But till now it's purpose is not clear to me ?
-
Thank you Luc Yes I know that link but I do not feel confident with that solution 1- I can't compile it because the post compile event wants to run mt.exe and I don't know why ? 2- As I can see it uses an uggly old fashion dos interface 3- At the first sight I thougt that the goal for that app was to create or edit Windows .job files and let Windows scheduller do the job. If so I do not understand why it needs 7 files of about 100k of source code to do that ? I'm afraid that this is just another scheduller ! But till now it's purpose is not clear to me ?
I think that wasn't meant for me; maybe it is your reply to Abhinav S? :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
I think that wasn't meant for me; maybe it is your reply to Abhinav S? :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
My need is to schedulle to run a C# application once a day for some days of the week And I provide an UI to set those days So I was trying to find out if the best way is to make a service to do that or to programaticaly try to make a new Windows task to run the app as an exe Thanks for your help / suggestion Olivier
Use a Windows Scheduled Task to schedule for only those days and times you want it to run.
-
you could tell Windows to run it once a day, then in your code skip the days that you don't want any action taken. day selection information could be kept in a settings file, a separate file, the registry, whatever, which some app could display and modify through a GUI. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Luc Pattyn wrote:
then in your code skip the days that you don't want
Ew. So how do you test it on those days? Or what if you change your mind?
-
Luc Pattyn wrote:
then in your code skip the days that you don't want
Ew. So how do you test it on those days? Or what if you change your mind?
Hello The idea of Luc was very simple (as most of good idea) Let say that I have a settings file giving the needed days (this is the case) When the application start it will check that files and decide to run the process or close So if the Windows scheduller start the application every days the task will only start for the needed days An independent UI (Web Page) can change the setting file at any time The Idea was great but unfortunately not for this case because the User can also choose the starting time
-
Hello The idea of Luc was very simple (as most of good idea) Let say that I have a settings file giving the needed days (this is the case) When the application start it will check that files and decide to run the process or close So if the Windows scheduller start the application every days the task will only start for the needed days An independent UI (Web Page) can change the setting file at any time The Idea was great but unfortunately not for this case because the User can also choose the starting time
I disagree; I don't think the application should be responsible for its own scheduling. And if you later have to develop other similar applications, you would likely wind up with a bunch of duplicate code. Having the scheduling handled outside the application allows it to be shared among any number of applications. And Windows already has a built-in Scheduler that will do what you want; why not use it?
-
Use a Windows Scheduled Task to schedule for only those days and times you want it to run.
Ok Have a look on the environnement The application should run on a server ONE user uses an interface (web page) on a remote machine to set up the days an time he wants to get some rapport The question is what would be the best way to automaticaly set up the Windows scheduller on the server when the user changes his mind ?
-
Ok Have a look on the environnement The application should run on a server ONE user uses an interface (web page) on a remote machine to set up the days an time he wants to get some rapport The question is what would be the best way to automaticaly set up the Windows scheduller on the server when the user changes his mind ?
Well that's a whole other situation than what you described in the original post. And in that case, I agree with a Windows Service that executes the task when specified. I have written such a scheduler. Tasks were scheduled in a database via whatever client (I used WinForms). I will further state that I stopped using my task scheduler when I made my report scheduler.
baranils wrote:
to get some rapport
I'll assume you mean report. Are the reports generated by Crystal or another report system? If so, I suggest a Service that executes the report more directly, without some other executable in between.
-
Well that's a whole other situation than what you described in the original post. And in that case, I agree with a Windows Service that executes the task when specified. I have written such a scheduler. Tasks were scheduled in a database via whatever client (I used WinForms). I will further state that I stopped using my task scheduler when I made my report scheduler.
baranils wrote:
to get some rapport
I'll assume you mean report. Are the reports generated by Crystal or another report system? If so, I suggest a Service that executes the report more directly, without some other executable in between.
Hello PIEBALDconsult
Well that's a whole other situation than what you described in the original post.
Not really :
My need is to schedulle to run a C# application once a day for some days of the week
And I provide an UI to set those daysAs I said my C# application do the job (getting date, create report) My application can also read the xml setings file created by the UI I can of course run my application as a service but I see some advantage to keep it as an exe file and try to les Windows schedulle it 1- As long as it only needs to run maximum once a day it is not efficient to let a servis running all the time 2- With an exe we keep the ability to manualy launch som "extra run" if needed
-
My need is to schedulle to run a C# application once a day for some days of the week And I provide an UI to set those days So I was trying to find out if the best way is to make a service to do that or to programaticaly try to make a new Windows task to run the app as an exe Thanks for your help / suggestion Olivier
I wrote some code for that and use it in a windows service: Scheduling Future Dates [^]
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
I wrote some code for that and use it in a windows service: Scheduling Future Dates [^]
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
Hello PIEBALDconsult
Well that's a whole other situation than what you described in the original post.
Not really :
My need is to schedulle to run a C# application once a day for some days of the week
And I provide an UI to set those daysAs I said my C# application do the job (getting date, create report) My application can also read the xml setings file created by the UI I can of course run my application as a service but I see some advantage to keep it as an exe file and try to les Windows schedulle it 1- As long as it only needs to run maximum once a day it is not efficient to let a servis running all the time 2- With an exe we keep the ability to manualy launch som "extra run" if needed
Don't think so small. If this project is a success they'll ask you to write other such reports that may have to run more than once a day or on demand. It'll be easier in the long run if you provide such flexibility from the start.
-
Don't think so small. If this project is a success they'll ask you to write other such reports that may have to run more than once a day or on demand. It'll be easier in the long run if you provide such flexibility from the start.
-
Yes of course, I agree with you, but practicaly I'll still be happy to understand how to setup the windows scheduller programatically Maybe by simply execute taskschd.exe using System.Diagnostics.Process.Start?
baranils wrote:
execute taskschd.exe
That's how I've done it in the past. But there oughta be a better way.
-
baranils wrote:
execute taskschd.exe
That's how I've done it in the past. But there oughta be a better way.