container.innerHTML += "<br />";
var br = document.createElement('br');
container.appendChild(br);
var grid = $("#grid");
var table = $('<table>'), tr, td;
grid.append(table);
for (var height = 0; height < 16; height++) {
tr = $('<tr>');
for (var width = 0; width < 10; width++) {
tr.append('<td></td>');
}
table.append(tr);
}
public class JobHost : IRegisteredObject
{
private readonly object _lock = new object();
private bool _shuttingDown;
public JobHost()
{
HostingEnvironment.RegisterObject(this);
}
public void Stop(bool immediate)
{
lock (_lock)
{
_shuttingDown = true;
}
HostingEnvironment.UnregisterObject(this);
}
public void DoWork(Action work)
{
lock (_lock)
{
if (_shuttingDown)
{
return;
}
work();
}
}
}
public static class MyHelper
{
private static readonly Timer _timer = new Timer(OnTimerElapsed);
private static readonly JobHost _jobHost = new JobHost();
public static void Start()
{
_timer.Change(TimeSpan.Zero, TimeSpan.FromHours(1));
}
public static void OnTimerElapsed(object sender)
{
_jobHost.DoWork(() =>
{
// action ...
});
}
}
public class Application : HttpApplication
{
protected void Application_Start()
{
// ....
MyHelper.Start();
}
}