|
-
February 11th, 2008, 06:24 AM
#1
restart application
hello,
I am storing some of my GUI settings in config file which is accessible to user. If user changes the settings then application has to be restrted with the updated settings.
As soon as settings are changed and saved i am doing Application.ExitThread();
and calling Application.Restart();
I found that Application.Restart() is not consistent. I am facing two problems here:
1). Some times it does not reflects the updated settings to config file before restart and start with previous settigns only.
2). Some times it doesn't terminate the current aprocess before starting the new application process.
Is there any better way to use Application.Restart() or so simply to restart the application?
Thanks.
-
February 11th, 2008, 08:29 AM
#2
Re: restart application
Why restart a complete application when just settings are changed...
Isn't it much better to simply re-initialize the application?
-
February 11th, 2008, 09:14 AM
#3
Re: restart application
Yeah, restarting the application (or anything like that) to get to a starting state is a bad idea. Nevermind C# or windows. Just from a, architectural point of view, it is a poor way to do things.
For example, you know those member variables you initialize directly like:
class MyClass
{
private int MyValue = 0;
}
There is no way to 'reset' those values without an init function to do it. So there is no magical method that a base class can provide that will restart your application.
Just create an init method that is in the constructor for your class that is also able to be called anywhere else that really does init all you variables. That means running through your code and making sure that all your members are initialized there. Even innocent things like "private List<Data> = new List<Data>();" need to be moved from the class level into the init function.
-
February 14th, 2008, 04:28 PM
#4
Re: restart application
There are reasons to reload an application.
Especially for an application that checks for updates before it is run (such as a clickonce deployed app). If I have users logged in and using my application, I find a bug, fix it, post an update. Being able to send a command to all the attached clients telling them to restart (and update in the process) is desireable and logical.
-
February 14th, 2008, 05:21 PM
#5
Re: restart application
 Originally Posted by crackersixx
There are reasons to reload an application.
....
So maybe before the discussion exceeds, we my ask the originator why HE wants to rerstart his app.
Last edited by JonnyPoet; February 14th, 2008 at 05:26 PM.
 Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|