views:

1004

answers:

5

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!

A: 

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

Ahmed Said
A: 

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..

Ben Scheirman
were is the ideal place to store those vars like lastruntime... is global.asa the only place?
Scott Kramer
could be in a database, or could simply come from HttpApplication state.
Ben Scheirman
A: 

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

Eduardo Molteni
A: 

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

Larsenal
+1  A: 

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

Micah
Seems like your post and/or site is gone... maybe just need to fix the URL?
Yadyn