473,785 Members | 2,325 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Restart, but after a delay

I need to restart my VB.NET 2.0 app but I need to delay the new
instance's start until I know the previous instance has ended and freed
up all use of its resources (DLLs). What I have is an app where the
EXE is basically a shell and there are multiple DLL "plug-in" modules.
Within the shell I have a "load new module" function which lets the
user import new plug-ins. When an updated plug-in is loaded, I can't
overwrite the DLL immediately since the DLL is in-use. What I am doing
is copying the new plug-in to a temporary location. Then when the app
starts, I check that location for new DLLs before I dynamically load
them. However, when I use Application.Res tart or
System.Diagnost ics.Process.Sta rt(Application. ExecutablePath) to start
my new instance, followed immediate by an "End" statement, the new
instance is starting before the old instance completely ends.
Therefore, when the new instance trys to copy the new DLLs from the
temp location to the application folder, I get an exception. Does all
this make sense? Any ideas? TIA... Steve

Jun 1 '06 #1
1 3404

Steve wrote:
I need to restart my VB.NET 2.0 app but I need to delay the new
instance's start until I know the previous instance has ended and freed
up all use of its resources (DLLs). What I have is an app where the
EXE is basically a shell and there are multiple DLL "plug-in" modules.
Within the shell I have a "load new module" function which lets the
user import new plug-ins. When an updated plug-in is loaded, I can't
overwrite the DLL immediately since the DLL is in-use. What I am doing
is copying the new plug-in to a temporary location. Then when the app
starts, I check that location for new DLLs before I dynamically load
them. However, when I use Application.Res tart or
System.Diagnost ics.Process.Sta rt(Application. ExecutablePath) to start
my new instance, followed immediate by an "End" statement, the new
instance is starting before the old instance completely ends.
Therefore, when the new instance trys to copy the new DLLs from the
temp location to the application folder, I get an exception. Does all
this make sense? Any ideas? TIA... Steve


You could try something like this:

Imports System.Diagnost ics

Private Sub LoadDlls()
Dim procs As Process()
Dim proc As Process
Dim currProcName As String

'Grab the current process name
currProcName = Process.GetCurr entProcess.Proc essName

'Look for all instances of that
' process and wait in a loop until
' there is only one instance of our
' process running
Do
procs = Process.GetProc essesByName(cur rProcName)
Loop While procs.Length > 1

' *** Load your DLL's here ***

End Sub

Basically, this code just waits until there is only one running
instance of the program in memory. At that point, you know that one
running instance has to be the one the code is running in right now, so
it's safe to modify the Dll's because any other instances of the
program have terminated completely.

Mike S

Jun 1 '06 #2

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

Similar topics

20
3035
by: Doug Thews | last post by:
I ran into an interesting re-pain delay after calling the Abort() method on a thread, but it only happens the very first time I call it. Every time afterward, there is no delay. I've got a delegate inside the UI that I call to update the progress meter. I use the Suspend() and Abort() methods based on button events. I can watch the progress meter increase just fine when the thread is running. When I select Start, I enable the Cancel...
5
1652
by: LL | last post by:
Hi, I use Applicaiton lever variable like this: Application = xxx; Do I need to restart the WWW service every time to reset it? I also have several Session variables. When Session_End event fire, all of them are null, right? Thanks.
5
1808
by: Daniel | last post by:
Hi, is the a way to prevent aspnet process to restart after web.config is modified? like, waiting for all sessions to close, or not restart at all ? Thank you, Daniel
3
2781
by: ad | last post by:
I want to renew all values of Application and Session. How can I restart application in program?
3
1427
by: Tedmond | last post by:
Dear all, Is it possible to restart a remote PC using .net? The PC did not join my domain but I know it's local admin login. Thanks for any help. Tedmond
3
2802
by: phocis | last post by:
I wrote a pair of functions to enable scoped or referenced setTimeout calls. I did this because I have an object factory that creates multiple objects and those objects need to delay a few calls on themselves at a certain point in time. This code works fine for normal objects. However, my issue occurs if at any point, an event object is passed across in IE. It seems, that events methods and variables in IE are PRIVATE (!) after the...
11
3796
by: Jon Slaughter | last post by:
Is there any way to start a terminated thread without using a pool or creating a new thread object? void counter() { clicks = 0; clock.Start(); while (counterActive) { clicks++;
5
3131
by: danfan46 | last post by:
Hi! I have a previous post on the subject that connect takes a long time. I uninstalled db2 completely. Installed V9.5 Installed fixpack 1 created das created an instance installed database sample.
3
4291
by: IdleBrain | last post by:
Gurus, I am trying to delay Windows Shutdown/Restart to perfrom cleanup and I am using the following code: protected override void WndProc(ref Message ex)
0
10341
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
9954
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8979
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...
0
6741
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
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.