|
-
May 21st, 2013, 01:01 PM
#1
Thread Starter
Frenzied Member
Scheduling Tasks
Hello. I have a small class library, each implementing the ITask interface:
Code:
Public Interface ITask
Property StartTime As DateTime
Property StopTime As DateTime
Property RunFrequency As TimeSpan
Sub Start()
Function Execute() As Integer
Sub Finish()
End Interface
I'm looking to allow my user to schedule these tasks. Basically a big list of tasks.. each one on it's own thread.
psuedo: If Now >= startTime and Now <= stopTime, Threading.Thread.Sleep(task.execute())
What controls could I use to make the scheduling look neat? How would I go about with the actual threading part? Would I need to add a Thread property to my ITask interface?
-
May 21st, 2013, 01:07 PM
#2
Re: Scheduling Tasks
Take a look at JMcIlhinney's thread on adding a pause to your code, if used properly you can do exactly what you're wanting to do:
Code:
Run task 1
Pause -x- time
Run task 2
Pause -y- time
Run task 3
Pause -z- time
etc.
The way that he structured the code, doesn't block the UI and it doesn't use a 'busy wait', which by the way Thread.Sleep will block the UI.
Last edited by dday9; May 21st, 2013 at 01:08 PM.
Reason: Run task 3 not Rune task 3
-
May 21st, 2013, 01:08 PM
#3
Re: Scheduling Tasks
 Originally Posted by Zach_VB6
How would I go about with the actual threading part? Would I need to add a Thread property to my ITask interface?
I think a very important question needs to be answered first: Do you want these ITask implementers to be able to start themselves ? Or do you intend to have a collection based object that takes ITask objects and start them when its their time ?
-
May 21st, 2013, 02:07 PM
#4
Thread Starter
Frenzied Member
Re: Scheduling Tasks
 Originally Posted by dday9
Take a look at JMcIlhinney's thread on adding a pause to your code, if used properly you can do exactly what you're wanting to do:
Code:
Run task 1
Pause -x- time
Run task 2
Pause -y- time
Run task 3
Pause -z- time
etc.
The way that he structured the code, doesn't block the UI and it doesn't use a 'busy wait', which by the way Thread.Sleep will block the UI.
Thank you for the link. Not sure how to "trigger" the start of the ITask object.
 Originally Posted by Niya
I think a very important question needs to be answered first: Do you want these ITask implementers to be able to start themselves ? Or do you intend to have a collection based object that takes ITask objects and start them when its their time ?
I think it would be better if I created a TaskHandler class that handled the collection of ITask objects and would start/stop them appropriately. I think the TaskHandler class should also "paint"/display the current schedule to the user
Is there a control that would be well suited for a scheduling type thing?
-
May 21st, 2013, 03:16 PM
#5
Re: Scheduling Tasks
 Originally Posted by Zach_VB6
Is there a control that would be well suited for a scheduling type thing?
I'm thinking that a simple grid could work well.
-
May 21st, 2013, 03:27 PM
#6
Thread Starter
Frenzied Member
Re: Scheduling Tasks
 Originally Posted by Niya
I'm thinking that a simple grid could work well.
I could bind a List(of ITask) to a DataGridView? How do you bind a list?
-
May 21st, 2013, 06:00 PM
#7
Re: Scheduling Tasks
You could bind a DataGridView by setting its DataSource property. If you do this through the property grid at design time, the designer will generate the columns in the DataGridView for you. At runtime, bind the list. Note though that only public properties are considered in data binding scenarios.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|