Hi,
I'm currently working on an application that will always run and check/fetch a set of records from my database. The program will do this probably for every 10 seconds (Will use a timer for this unless there's a better way). The table consists of data regarding executable files and their corresponding location in the server.
Table structure.
Now when my program loops over these Waiting records, I need to run this executable file, set the Status column to 'In Process' then wait for them to finish and set the Status column to 'Finished'. Currently my approach is something like...Code:Filename Status 'Could be Waiting, In Process or Finished'
Setting the Status to 'Finished' is the problem I'm having now as I don't know how to check whether the Process has ended or not. Then I thought of adding the Procedure SetFinished after the line p = Process.Start like shown below.Code:Public Sub SetInProgress(ByVal Filename As String) 'Do updates here. End Sub Public Sub SetFinished(ByVal Filename As String) 'Do updates here. End Sub Public Sub Run(ByVal Filename as String) Dim p As New Process p = Process.Start(Filename) End Sub Public Sub Main() For Each row As DataRow In DataTable.Rows Run(row("Filename")) SetInProgress(row("Filename")) Next End Sub
But the above code will prevent me from running multiple processes at the same time. Also I need to have the ability to Stop a process from running.Code:Public Sub Run(ByVal Filename as String) Dim p As New Process SetInProgress() p = Process.Start(Filename) SetFinished() End Sub
How can I do this?
Thanks.




Reply With Quote