|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Restart, but after a delayI 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.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 Steve wrote:
Show quoteHide quote > I need to restart my VB.NET 2.0 app but I need to delay the new You could try something like this:> 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.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 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
what's available in WMI
File sitting on a network drive is still open by another applicati Deleted row in dataset?? popup windows killer Why choose SQL Express over Access? Offset lines appearing over form after delay (NVIDIA Chipset) "select case" statement optimization in VB and C# problems Soap Formatter namespace not found loading frames asp My object/class/whatever |
|||||||||||||||||||||||