Why you don't use the method Application_Start in the global.asax This method only call when the app is start, and if you put in a static variable the content any user can acces this content.
Useful link's http://en.wikipedia.org/wiki/Global.asax http://renefc3.wordpress.com/2012/04/21/vida-util-variaveis-asp-net-variavel-estatica-cache-e-variavel-de-sessao/ (portuguese from brazil) On Sat, Feb 11, 2012 at 8:42 AM, Reuben Bartolo <reuben.bart...@gmail.com>wrote: > What you are trying to achieve there, is called the Singleton Design > Pattern. > I suggest you do some research into it, and any pitfalls it might have. > > Regards, > Reuben Bartolo > http://whatiseeinit.blogspot.com/ > > > On 10 February 2012 19:26, Guilherme Utrabo <utr...@gmail.com> wrote: > >> Hello everybody. Need some help with the "lock" statement. >> I have the following structure on my Global.asax: >> >> private static IList MyList; >> private static object syncObject = new object(); >> void Application_PreRequestHandlerExecute(Object sender, EventArgs e) >> { >> if (MyList == null) >> { >> lock (syncObject) >> { >> MyList = new ArrayList(); >> MyList.Add("test"); >> } >> } >> } >> >> When my application starts I want to populate "MyList" and then share it >> between the users. >> But I want to make it once. Is my structure really thread safe? Should I >> use the lock on "MyList" instead of using it on the "syncObject"? >> >> Thanks in advance. >> >> Regards, >> Guilherme >> >> -- >> You received this message because you are subscribed to the Google >> Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML >> Web Services,.NET Remoting" group. >> To post to this group, send email to dotnetdevelopment@googlegroups.com >> To unsubscribe from this group, send email to >> dotnetdevelopment+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en >> or visit the group website at http://megasolutions.net >> > > -- > You received this message because you are subscribed to the Google > Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML > Web Services,.NET Remoting" group. > To post to this group, send email to dotnetdevelopment@googlegroups.com > To unsubscribe from this group, send email to > dotnetdevelopment+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en > or visit the group website at http://megasolutions.net > -- Rene Felix Correa Analista Desenvolvedor http://renefc3.wordpress.com -- You received this message because you are subscribed to the Google Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting" group. To post to this group, send email to dotnetdevelopment@googlegroups.com To unsubscribe from this group, send email to dotnetdevelopment+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en or visit the group website at http://megasolutions.net