Question

I've heard Jeff and Joel discuss on a podcast what they called a "Heartbeat" which essentially is creating something that acts similar to running a windows service in an website. I was hoping to get some more insight into how something like this would be implemented. Has anyone implemented something like this before and what did you use it for?

Thanks!

Was it helpful?

Solution

I found the answer in a combination of places. I took what Jeff Attwood did for stackoverlow here as well as the Code Project article and made something that is completely reusable and able to easily be hooked up using an IoC tool. I've posted the full details here

OTHER TIPS

Basically you use a web page to kick off a process... but you put a cap on how often the process can run.

Something like this:

TimeSpan timeSinceLastRun = DateTime.Now.Subtract(lastRunTime);

if(timeSinceLastRun > interval) {
    RunCustomProcess();
    lastRunTime = DateTime.Now;
}

this way you just have to ensure that occasionally someone (or some program) visits the page. Hitting the page many times won't adversely affect your process..

This Code project article: Simulate a Windows Service using ASP.NET to run scheduled jobs, explains it all.

You can use ASP.NET Health Monitoring and wire up something to WebHeartbeatEvent.

We are implementing something like that between the client and server, as we have windows forms client and WCF service acts as a server.

The aim of the heartbeat is to sayd "I am still alive" from the server side.

Check this link for introduction for Heartbeat in WCF

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top