I'm wanting to stop a System.Timers.Timer that is running in a SignalR hub after a client closes a window/tab containing the active connection. 
I have tried sending a bool value to the server by calling server code to notify the server the client is still connected or not, but it's not currently working.
window.onbeforeunload = function () {
    profile.server.setIsConnected(false);
};
Server Side:
public ProfileHub()
{  
    timer = new Timer(15000);
    timer.Elapsed += (sender, e) => { timer_Elapsed(sender, e, _isActive); };
    timer.AutoReset = false;
}
[Authorize]
private void timer_Elapsed(object sender, ElapsedEventArgs e, bool active)
{            
    timer.Stop();
    if (active)
    {
        System.Diagnostics.Debug.WriteLine("Timer Started");
        timer.Start();
    }
    else
    {
        System.Diagnostics.Debug.WriteLine("Timer Stopped");
        return;
    }
    // process code
}
[Authorize]
public void SetIsActive(bool isActive)
{
    _isActive = isActive;
}
Is this possible and am I on the right track? I suspect it has something to do with the anonymous delegate for timer.Elapsed, but I'm not entirely sure.
 
     
    