Mimic Session object (of ASP.NET) in Winform app

  • Thread starter Thread starter John Indra
  • Start date Start date
J

John Indra

Hello all...

I need to have global data available within the lifetime of my Winform
app, accessible from any objects this application might spring at
runtime.

In ASP.NET, I can just create this holder object, put this object in
(System.Web.SessionState.HttpSessionState)Session object, and whenever
I need to access the global data from virtually any object having
access to the Session object, I just call

((HolderObjectType)Session["TheHolderObject"]).TheData

In Winform, I was hoping that I can rely on
System.Windows.Forms.Application object and put something in it.
Apparently the System.Windows.Forms.Application can't store data like
the System.Web.SessionState.HttpSessionState object.

Is there something obvious that I miss? If not, what is your
recommendation to achieve what I want?

Thanks in advance,

/john
 
What's wrong with creating an internal or public class with static
properties?

Once initialized, these can be simply accessed from any object in your
AppDomain by using the classname followed by the static property name.

Cheers,
Wim Hollebrandse
http://www.wimdows.com
http://www.wimdows.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top