Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

.NET Scheduled Timer

, 16 Sep 2005 CPOL
A timer that easily supports absolute schedules like run at 4:00 AM every day or at 5:00 PM on Fridays..
scheduletimer_demo.zip
ReportTimerTest
bin
Release
ReportTimerTest.exe
ScheduleTimer.dll
App.ico
ScheduleTimer
bin
Release
ScheduleTimer.dll
ScheduledItems
StopTest
App.ico
TimerTest
bin
Release
ScheduleTimer.dll
TimerTest.exe
App.ico
TransClock
bin
Release
ScheduleTimer.dll
TransClock.exe
App.ico
ScheduleTimer.png
TransClock.build
scheduletimer_src.zip
App.ico
App.ico
App.ico
App.ico
ScheduleTimer.png
TransClock.build
transclock_demo.zip
App.ico
App.ico
/***************************************************************************
 * Copyright Andy Brummer 2004-2005
 * 
 * This code is provided "as is", with absolutely no warranty expressed
 * or implied. Any use is at your own risk.
 *
 * This code may be used in compiled form in any way you desire. This
 * file may be redistributed unmodified by any means provided it is
 * not sold for profit without the authors written consent, and
 * providing that this notice and the authors name is included. If
 * the source code in  this file is used in any commercial application
 * then a simple email would be nice.
 * 
 **************************************************************************/

using System;
using System.Collections;

namespace Schedule
{

	/// <summary>
	/// There have been quite a few requests to allow scheduling of multiple delegates and method parameter data
	/// from the same timer.  This class allows you to match the event with the time that it fired.  I want to keep
	/// the same simple implementation of the EventQueue and interval classes since they can be reused elsewhere.
	/// The timer should be responsible for matching this data up.
	/// </summary>
	public class EventInstance : IComparable
	{
		public EventInstance(DateTime time, IScheduledItem scheduleItem, object data)
		{
			Time = time;
			ScheduleItem = scheduleItem;
			Data = data;
		}
		public DateTime Time;
		public IScheduledItem ScheduleItem;
		public object Data;

		public int CompareTo(object obj)
		{
			if (obj is EventInstance)
				return Time.CompareTo(((EventInstance)obj).Time);
			if (obj is DateTime)
				return Time.CompareTo((DateTime)obj);
			return 0;
		}
	}

}
 
 

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Andy Brummer
Architect Michael & Susan Dell Foundation
United States United States
I'm a web developer, math and physics enthusiast, and all around great guy. I live in Austin TX and love using technology to change people's lives for the better.
Follow on   Twitter

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150414.1 | Last Updated 16 Sep 2005
Article Copyright 2004 by Andy Brummer
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid