473,385 Members | 1,397 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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.Restart or
System.Diagnostics.Process.Start(Application.Execu tablePath) 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 3323

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.Restart or
System.Diagnostics.Process.Start(Application.Execu tablePath) 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.Diagnostics

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

'Grab the current process name
currProcName = Process.GetCurrentProcess.ProcessName

'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.GetProcessesByName(currProcName)
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
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...
5
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...
5
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
by: ad | last post by:
I want to renew all values of Application and Session. How can I restart application in program?
3
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
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...
11
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
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...
3
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)
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

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.