public void RegisterSession(ISession session) { var mutex = new Mutex(false, session.Id.ToString()); try { mutex.WaitOne(); var existingSession = _repository.GetSession(session.Id); //Thread.Sleep(ThreadTestDelay); if (existingSession == null) { _repository.AddSession(session); _coutnerBusiness.UpdateSessionCounters(); } else { if (session.ApplicationVersionId != existingSession.ApplicationVersionId) { var ex = new ArgumentException("The session belongs to a different application version."); ex.Data.Add("SessionId", session.Id); ex.Data.Add("ApplicationVersionId", session.ApplicationVersionId); ex.Data.Add("ExistingApplicationVersionId", existingSession.ApplicationVersionId); throw ex; } _repository.UpdateSessionUsage(session.Id, DateTime.UtcNow); } } finally { mutex.ReleaseMutex(); } }
public ActionResult Reset(FormCollection collection) { _counterBusiness.ClearSessionCounters(); _counterBusiness.UpdateSessionCounters(); return(View()); }