I have a backgroundworker that copies some files. After it finishes copying the files, I want to launch an application. The problem I am running into is that while the files are copying, it calls the code to launch the application, so it runs into a file in use error. Is there a check I can do to ensure that a certain method is only called when the background worker has completed?
private void LaunchApplication(string targetPath, string targetExecutable)
{
CopyFiles();
Process.Start(Path.Combine(targetPath, targetExecutable));
}
CopyFiles is called within the DoWork method of the BackGroundWorker. I want this to completely finsih before Process.Start... is called. Now I have several executables tied to several buttons, so I can't put the Process.Start... in the RunWorkerCompleted event.