[program-l] Re: form and objects visual c#

  • From: "Juan Hernandez" <juanhernandez98@xxxxxxxxx>
  • To: <program-l@xxxxxxxxxxxxx>
  • Date: Sun, 24 May 2015 23:28:15 -0700

I told you I was tired. :)

I instead used system.Lazy, and created a singleton class, and got got it
working. Thank you so much for your help.




-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx [mailto:program-l-bounce@xxxxxxxxxxxxx] On
Behalf Of Soronel Haetir
Sent: Sunday, May 24, 2015 10:27 PM
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: form and objects visual c#

Why wouldn't you make the settings a static member of the Program class that
should be part of your project?

The Program class is where you find the entry point function that creates the
instance of your initial form.

On 5/24/15, Juan Hernandez <juanhernandez98@xxxxxxxxx> wrote:

Hi All,



I am really tired, and that's probably why I'm missing something so
obvious.



I have form1, and form2.



I have a Settings class that stores all my settings while the
application is running. The settings object on initialization access
a xml file with all of the settings my application needs to run.



Now, if I initialize this object in form1, Settings appSettings = new
Settings();



All is good. I can get all of my settings.



Now, we have form2. I know if I just initialize the settings object
in form2, it'll just get a clean settings pull from the xml file. I
instead just want to access one settings object application wide.



Because if I change fields in form1's settings object, when I access
form2, the things I updated in form1, willnot be available to form2.



I could save everytime something is changed in settings to the xml
file, but this would involve a lot of disk access.



I have a timer that saves settings automaticly every 3 minutes. But
If I need a new setting for form2, it will not be there since it
hasn't been three minutes since I called form2.



I hope this isn't too confusing. I want to access a single object
from multiple forms. Is this possible?

Any help will be appreciated.






--
Soronel Haetir
soronel.haetir@xxxxxxxxx
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

Other related posts: