By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,786 Members | 1,131 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,786 IT Pros & Developers. It's quick & easy.

How to access the Global object

P: n/a
Hi,

I have made a method in Global.asax called from Application_Start event
that loads some cache data from database to Application scope objets.

This is necessary because this is some data from data that don't change
very often.....but it could change.

So I have my method in Global.asax (it can't be Shared because it would
lost Application object scope), and I would like to call it manually to
refresh the cache when necessary.

Other thing I tryed is to move the method to a new class and make it
shared, but "Application" is not recognized.

How can I access Application object from outside Global.asax and use it
in a Shared sub? or How can I call the "Global" object instance from a
page?

This is the method's code :

Public Sub ReCargarCache()

Application.Lock()

Application(DC.TipoDeOperacion.ToString) =
StoredProcedures.GetIdNameTipoDeOperacion.Tables(0 )
Application(DC.Shipper.ToString) =
StoredProcedures.GetIdNameShipper.Tables(0)
Application(DC.Incoterm.ToString) =
StoredProcedures.GetIdNameIncoterm.Tables(0)
Application(DC.MercadoShipper.ToString) =
StoredProcedures.GetIdNameMercadoShipper.Tables(0)
Application("Consignatario") =
StoredProcedures.GetIdNameProveedorDeServicioBySer vicio(CInt(eTipoDeServicio.eTipoDeServicioConsigna tario)).Tables(0)
Application("Notify") =
Application(DC.Localidad.ToString) =
StoredProcedures.GetIdNameLocalidad.Tables(0)
Application(DC.Puerto.ToString) =
StoredProcedures.GetIdNamePuerto.Tables(0)
Application("Agente") =
StoredProcedures.GetIdNameProveedorDeServicioBySer vicio(CInt(eTipoDeServicio.eTipoDeServicioAgenteMa ritimo)).Tables(0)
Application(DC.Motonave.ToString) =
StoredProcedures.GetIdNameMotonave.Tables(0)
Application(DC.Terminal.ToString) =
StoredProcedures.GetIdNameTerminal.Tables(0)

Application.UnLock()

End Sub

Regards
Fabio

Nov 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 23 Nov 2005 11:24:08 -0800, "Fabio Cavassini"
<ca********@gmail.com> wrote:
How can I access Application object from outside Global.asax and use it
in a Shared sub? or How can I call the "Global" object instance from a
page?


You could always put this code in a Shared Sub outside of global.asax
and use a different synchronization technique, for instance
Monitor.Enter, Monitor.Exit, or a ReaderWriterLock object.
http://msdn.microsoft.com/library/de...classtopic.asp

--
Scott
http://www.OdeToCode.com/blogs/scott/
Nov 24 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.