G
George
I am trying to implement postponed initialization (object is not initialize
till requested).
public class clsStore
{
volatile List<clsPictureGroup> _lstPictureGroups = null;
public List<clsPictureGroup> PictureGroups
{
get
{
if (_lstPictureGroups == null)
{
lock (this)
{
if (_lstPictureGroups == null)
_lstPictureGroups = LoadPictureGroup();
}
}
return _lstPictureGroups;
}
}
}
Obviously this code suppose to run in multithreaded enviroment in ASP.NET.
Anyone sees any problem in this code?
As far as i can see there is no 'race' condition here and code is safe.
Thanks
George.
till requested).
public class clsStore
{
volatile List<clsPictureGroup> _lstPictureGroups = null;
public List<clsPictureGroup> PictureGroups
{
get
{
if (_lstPictureGroups == null)
{
lock (this)
{
if (_lstPictureGroups == null)
_lstPictureGroups = LoadPictureGroup();
}
}
return _lstPictureGroups;
}
}
}
Obviously this code suppose to run in multithreaded enviroment in ASP.NET.
Anyone sees any problem in this code?
As far as i can see there is no 'race' condition here and code is safe.
Thanks
George.