scheduler

  • Thread starter Thread starter Brian Henry
  • Start date Start date
B

Brian Henry

Is there any information out there on how to build a good schedule
application that i can tell it at 1pm do this or at midnight do that?
thanks!
 
Brian Henry said:
Is there any information out there on how to build a good schedule
application that i can tell it at 1pm do this or at midnight do that?
thanks!

Just write a .NET console app and then use the scheduler built into windows
to "schedule" it. :)

Control Panel->Scheduled Tasks

Greg
 
cant do that, this needs to be a windows service that will be doing
different tasks in the application dependent on a custom schedule users set
up on their client systems... kind of like scheduled reporting and such
 
cant do that, this needs to be a windows service that will be doing
different tasks in the application dependent on a custom schedule users set
up on their client systems... kind of like scheduled reporting and such

You can still use the task scheduler... In the windows service, you
could override the ServiceBase.OnCustomCommand method. This allows your
service to receive a custom command with a numeric value in the range of
128 to 256. So, you could associate a numeric value with each of the
tasks (it could be a TaskType enum :).

Then, you have your windows program that is the interface that the user
sets up the schedule. The schedule is a task in the task scheduler.
What the task run is a simple little windows program with no gui that
takes the task number on the command line. All the program does is
simply call your services OnCustomCommand method:

Dim myService As ServiceController = New ServiceController ("MyServiceName")
If myService.Status = ServiceControllerStatus.Running Then
myService.ExecuteCommand (Convert.ToInt32 (args(0))

End IF

You service would might do something like:

Protected Override Sub OnCustomCommand (ByVal command As Integer)
' You might use the ThreadPool to que a job or you could spawn
' a thread if you like.
Select Case command
Case 128
' code to stick the associated command into a thread pool?
Case 129
' code to stick the associated command into a thread pool?
End Select
End Sub

Now, sticking the actual task in the task scheduler is the hardest part
- fortunately, there are several .NET libraries to accomplish this :)
Here is one I wrote:

http://mtogden.com/~tom/files/SchedulingAgent.NET.zip

It is the C# source code. Anyway, that is one idea :)
 
I don't want to use a task scheduler from windows at all, because it could
change in the future how it works, actually i know for a fact windows vista
is changing how it works drastically.
 
I don't want to use a task scheduler from windows at all, because it could
change in the future how it works, actually i know for a fact windows vista
is changing how it works drastically.

Well... If you don't want to use the scheduler, then another choice
is to use a timer. I would look at system.threading.timer or
system.timers.timer. Especially if your going to use these in a windows
service environment.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top