I would like to know in how the Session locking mechanism work and how I can lock a variable and its respective child objects for multiple reads/exclusive write in a server farm environment.
Scenario The web farm will use 3 Windows 2003 servers, each server as its own app domain for the Web application. The sesion object is saved on SQL Server 2005. The object to use in my web app is at follows: MySampleClass = class { public string Id; public Dictionary Data; public List Commands; public CustomClass2 MoreData; }
where customClass 1 and 2 are business classes that are part of the application.
now in one of the web pages, code will look like:
Session["myObj"] = new MySampleClass();
in other pages:
MySampleClass = (MySampleClass)Session["myObj"];
//Is Session["myObj"] accessed in a multiple reader/exclusive writer mode? if so is it locking just the variable or the whole contents? MySampleClass.Commands.Add("sample string"); MySampleClass.Commands.RemoveAt(0); //More CRUD changes //Are these changes available to other pages as soon as I finish the CRUD changes?
let me know if you need more details