Problem running multiple external apps

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2005
Posts: 75
Reputation: purplegerbil is an unknown quantity at this point 
Solved Threads: 6
purplegerbil's Avatar
purplegerbil purplegerbil is offline Offline
Junior Poster in Training

Problem running multiple external apps

 
0
  #1
Nov 30th, 2007
Hi,

I have a class that runs an external ap using shell then waits till the app is quit before carrying on.

Does anybody know if it is possible to start an app say by clicking a button then be told when the app has closed. The app can be open more than once.

The problem I have is when the code is run everything stops till the app has finished.

Hope this makes sense.

Here is the code I have so far:

  1. Public Function StartAndWait(ByVal ProcessPath As String, ByVal Licence As Integer)
  2. Dim startProcess As System.Diagnostics.Process
  3. Try
  4. startProcess = New System.Diagnostics.Process()
  5. startProcess.StartInfo.FileName = ProcessPath
  6. startProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
  7. startProcess.Start()
  8.  
  9. 'Wait until the process passes back an exit code
  10. startProcess.WaitForExit()
  11.  
  12. ' Check Exit code to see if process finished without error.
  13. If startProcess.ExitCode <> 0 Then
  14. MessageBox.Show("Exit Code: " & startProcess.ExitCode)
  15. End If
  16.  
  17. 'Free resources associated with this process
  18. startProcess.Close()
  19.  
  20. StartAndWait = True
  21.  
  22. Catch
  23. StartAndWait = False
  24. MessageBox.Show("Could not start process " & ProcessPath, "Error")
  25. End Try
  26. End Function
purpleGERBIL
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 169
Reputation: ptaylor965 is an unknown quantity at this point 
Solved Threads: 19
Sponsor
ptaylor965's Avatar
ptaylor965 ptaylor965 is offline Offline
Junior Poster

Re: Problem running multiple external apps

 
0
  #2
Dec 1st, 2007
I would try using Multi-Threading

Make the main thread continue running your application and the NEW Multi-Thread the open the other application

when the application is running the new thread will pause but your main app will continue to run also when the external app is closed the new thread will continue (add a msgbox in the new thread) and then the thread will close



Multi-Threading
http://www.taylorsnet.co.uk/SourceCo...px?SourceID=20
Peter Taylor
Visual Basic.NET Application Developer

TaylorsNet
http://www.taylorsnet.co.uk
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 75
Reputation: purplegerbil is an unknown quantity at this point 
Solved Threads: 6
purplegerbil's Avatar
purplegerbil purplegerbil is offline Offline
Junior Poster in Training

Re: Problem running multiple external apps

 
0
  #3
Dec 1st, 2007
Thanks for your reply. I will give it a go on Monday (work). I'm new to VB.NEt. In the process of moving from VB6.

The link you added looks great as well.

Cheers,
PG
purpleGERBIL
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC