Click here to Skip to main content
12,946,164 members (51,296 online)
Click here to Skip to main content

Stats

755.1K views
32.5K downloads
352 bookmarked
Posted 23 Mar 2004

.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..
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
App.ico
App.ico
App.ico
App.ico
ScheduleTimer.png
TransClock.build
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>
	/// This is an empty filter that does not filter any of the events.
	/// </summary>
	public class Filter : IResultFilter
	{
		public static IResultFilter Empty = new Filter();
		private Filter() {}

		public void FilterResultsInInterval(DateTime Start, DateTime End, ArrayList List)
		{
			if (List == null)
				return;
			List.Sort();
		}
	}

	/// <summary>
	/// This causes only the first event of the interval to be counted.
	/// </summary>
	public class FirstEventFilter : IResultFilter
	{
		public static IResultFilter Filter = new FirstEventFilter();
		private FirstEventFilter() {}

		public void FilterResultsInInterval(DateTime Start, DateTime End, ArrayList List)
		{
			if (List == null)
				return;
			if (List.Count < 2)
				return;
			List.Sort();
			List.RemoveRange(1, List.Count-1);
		}
	}

	/// <summary>
	/// This causes only the last event of the interval to be counted.
	/// </summary>
	public class LastEventFilter : IResultFilter
	{
		public static IResultFilter Filter = new LastEventFilter();
		private LastEventFilter() {}

		public void FilterResultsInInterval(DateTime Start, DateTime End, ArrayList List)
		{
			if (List == null)
				return;
			if (List.Count < 2)
				return;
			List.Sort();
			List.RemoveRange(0, List.Count-1);
		}
	}

}

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
Software Developer (Senior) Standard Beagle Studios
United States United States
I co-founded Standard Beagle Studio, a software development consulting service in Austin Texas with my wife Cindy Brummer. We focus mostly on web projects, but have built some react native mobile apps, and even a windows screen saver or two.

I started my career back when ASP pages were state of the art, and IE3 was considered a web browser. I've worked with Microsoft technologies for most of that time, and have recently branched out into node, wordpress, and react native applications.

I'm a web developer, math and physics enthusiast, father of 2, and all around great guy. I live in Austin TX and love using technology to change people's lives for the better. When I manage scrape together some spare time, I build generative art at curvature of the mind.

You may also be interested in...

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