473,763 Members | 7,541 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Self-restarting application

GTi
Does anyone have any good code for a self restarting application?
Sometimes I need to exit my application and start it again, what is the
best method of doing this in a windows form application.
The reason why I want to this is complicated, so a restart is faster
and more easier whey of doing it.

Jan 25 '06 #1
7 26758
System.Windows. Forms.Applicati on.Restart();

Marc
Jan 25 '06 #2
Hi,

"Marc Gravell" <mg******@rm.co m> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
System.Windows. Forms.Applicati on.Restart();


Note that this only works in 2.0 , in 1.X there is no Restart() method
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jan 25 '06 #3
Hi,

"GTi" <tu****@gmail.c om> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.com...
Does anyone have any good code for a self restarting application?
Sometimes I need to exit my application and start it again, what is the
best method of doing this in a windows form application.
The reason why I want to this is complicated, so a restart is faster
and more easier whey of doing it.


If you are using 2.0 you have a Restart method. if you are in 1.X you could
use a workaround, like spawning a new process (the spawned .exe can be
embedded in your original one) , you pass as a parameter the path to your
executable and simply exit the app, the spawned process is now still running
and it does simply wait until your original finished, and create the same
process again ( using the parameter passed before ) . It may sounds complex
but it's very easy really

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jan 25 '06 #4
GTi
Marc Gravell wrote:
System.Windows. Forms.Applicati on.Restart();

Marc


Hi hi - how thoughtful by MS.

Next question.
Can I put this anywhere in my code - just where I detect when I should
restart ?
Not in any FormClosing metods ?

Jan 25 '06 #5
Technically - probably

In reality, you'd be wise to bring things to a logical conclusion first,
particularly if you have other threads playing with unmanaged resources etc;
I'm not sure how aggressive this method is in terms of aborting threads etc,
and I wouldn't want my lazy-disk-writing to get killed in the middle of a
file for an everyday reason.

Myself, I'd be paranoid and close down everything cleanly, and essentially
use this as a last line in my Main() - i.e. something like:

static void Main() {
bool restart;
using(SomeForm form = new SomeForm()) {
form.ShowDialog ();
restart = form.RestartApp lication;
}
if(restart)
Application.Res tart();
}

You might get away with calling it elsewhere, but on your own head ;-p

Marc
Jan 25 '06 #6
GTi

Marc Gravell wrote:
Technically - probably

In reality, you'd be wise to bring things to a logical conclusion first,
particularly if you have other threads playing with unmanaged resources etc;
I'm not sure how aggressive this method is in terms of aborting threads etc,
and I wouldn't want my lazy-disk-writing to get killed in the middle of a
file for an everyday reason.

Myself, I'd be paranoid and close down everything cleanly, and essentially
use this as a last line in my Main() - i.e. something like:

static void Main() {
bool restart;
using(SomeForm form = new SomeForm()) {
form.ShowDialog ();
restart = form.RestartApp lication;
}
if(restart)
Application.Res tart();
}

You might get away with calling it elsewhere, but on your own head ;-p

Marc


OK - It will just terminate the program where the line is.
It will not call any FormClosing metods.
Nice to know:
Then I just use a bool variables to indicate if it need a Restart at
the end of program.
Tx Marc

Jan 25 '06 #7
Hello GTi,

One of the solutions: you can build all main logic in separate DLL. Main
app is a simple controlling EXE that load dependent DLL in different ApplicationDoma ins.
If u need to restart app - just reload appdomain. This way, for example,
is used in SQLServer to keep in reliable.

Take into account that this solution has disadvantages - inter-appdomains
calls are expensive. You need carefully design you app in this case

G> Does anyone have any good code for a self restarting application?
G> Sometimes I need to exit my application and start it again, what is
G> the
G> best method of doing this in a windows form application.
G> The reason why I want to this is complicated, so a restart is faster
G> and more easier whey of doing it.
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/members/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Jan 25 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9638
by: Jim Jewett | last post by:
Normally, I expect a subclass to act in a manner consistent with its Base classes. In particular, I don't expect to *lose* any functionality, unless that was the whole point of the subclass. (e.g., a security-restricted version, or an interface implementation that doesn't require a filesystem.) One (common?) exception seems to occur in initialization. I understand stripping out arguments that your subclass explicitly handles or...
2
4715
by: Marc | last post by:
Hi all, I was using Tkinter.IntVar() to store values from a large list of parts that I pulled from a list. This is the code to initialize the instances: def initVariables(self): self.e = IntVar() for part, list in info.masterList.items():
15
2596
by: Ralf W. Grosse-Kunstleve | last post by:
****************************************************************************** This posting is also available in HTML format: http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html ****************************************************************************** Hi fellow Python coders, I often find myself writing:: class grouping:
18
2282
by: Ralf W. Grosse-Kunstleve | last post by:
My initial proposal (http://cci.lbl.gov/~rwgk/python/adopt_init_args_2005_07_02.html) didn't exactly get a warm welcome... And Now for Something Completely Different: class autoinit(object): def __init__(self, *args, **keyword_args): self.__dict__.update(
4
2787
by: David Coffin | last post by:
I'd like to subclass int to support list access, treating the integer as if it were a list of bits. Assigning bits to particular indices involves changing the value of the integer itself, but changing 'self' obviously just alters the value of that local variable. Is there some way for me to change the value of the BitSequence object itself? I've also tried wrapping and delegating using __getattr__, but I couldn't figure out how to handle...
4
1821
by: marek.rocki | last post by:
First of all, please don't flame me immediately. I did browse archives and didn't see any solution to my problem. Assume I want to add a method to an object at runtime. Yes, to an object, not a class - because changing a class would have global effects and I want to alter a particular object only. The following approach fails: class kla: x = 1
24
2298
by: Peter Maas | last post by:
The Python FAQ 1.4.5 gives 3 reasons for explicit self (condensed version): 1. Instance variables can be easily distinguished from local variables. 2. A method from a particular class can be called as baseclass.methodname(self, <argument list>). 3. No need for declarations to disambiguate assignments to local/instance variables.
84
7218
by: braver | last post by:
Is there any trick to get rid of having to type the annoying, character-eating "self." prefix everywhere in a class? Sometimes I avoid OO just not to deal with its verbosity. In fact, I try to use Ruby anywhere speed is not crucial especially for @ prefix is better- looking than self. But things grow -- is there any metaprogramming tricks or whatnot we can throw on the self? Cheers,
13
12019
by: Kurda Yon | last post by:
Hi, I found one example which defines the addition of two vectors as a method of a class. It looks like that: class Vector: def __add__(self, other): data = for j in range(len(self.data)): data.append(self.data + other.data)
6
1814
by: Bart Kastermans | last post by:
I am playing with some trees. In one of the procedures I wrote for this I am trying to change self to a different tree. A tree here has four members (val/type/left/right). I found that self = SS does not work; I have to write self.val = SS.val and the same for the other members (as shown below). Is there a better way to do this? In the below self is part of a parse tree, F is the parse tree of a function f with argument x. If a node...
0
9563
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10144
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9997
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9937
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8821
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7366
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.