Micah
Micah

Reputation: 116140

Creating a "Heartbeat" or Windows-Service-Like functionality in Asp.Net

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!

Upvotes: 1

Views: 9599

Answers (5)

Micah
Micah

Reputation: 116140

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

Upvotes: 4

Larsenal
Larsenal

Reputation: 51176

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

Upvotes: 0

Eduardo Molteni
Eduardo Molteni

Reputation: 39443

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

Upvotes: 0

Ben Scheirman
Ben Scheirman

Reputation: 40981

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

Upvotes: 0

Ahmed
Ahmed

Reputation: 7238

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

Upvotes: -1

Related Questions