Got a little issue with a small program I'm writing. I'm attempting to run different tasks in there own processes, waiting until each is done while keeping the UI responsive. So far it works exactly how I want it until I try to reuse some of those processes....here is a sample of the code:
This is a over simplification of what's going on but it gets the point across. So it works exactly as expected, a button is pressed and the sequence starts. As each task gets disposed it recalls the StartFixing statement which then calls the next one in order until they are all done. BUT when I go to do it a second time the Disposed never fires assuming since it's already disposed. How do I recreate the same named process so it can be reused and still have it fire the disposed event?
-Allan
VB.NET:
Private WithEvents TaskOneProcess As Process
Private WithEvents TaskTwoProcess As Process
Private WithEvents TaskThreeProcess As Process
Private CurrentProcess as Integer = 0
Private Sub StartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartButton.Click
CurrentProcess=1
StartButton.Enabled = False
Call StartFixing()
End Sub
Private Sub StartFixing()
Select Case CurrentProcess
Case 1
CurrentProcess = 2
Call TaskOne
Case 2
CurrentProcess = 3
Call TaskTwo
Case 3
CurrentProcess = 4
Call TaskThree
Case 4
StartButton.Enabled = True
CurrentProcess = 0
End Select
End Sub
Private Sub TaskOne()
Using TaskOneProcess
' Do a bunch of stuff here
End Using
End Sub
Private Sub TaskOneProcess_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles TaskOneProcess.Disposed
Call StartFixing()
End Sub
Private Sub TaskTwo()
Using TaskTwoProcess
' Do a bunch of stuff here
End Using
End Sub
Private Sub TaskTwoProcess_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles TaskTwoProcess.Disposed
Call StartFixing()
End Sub
Private Sub TaskThree()
Using TaskThreeProcess
' Do a bunch of stuff here
End Using
End Sub
Private Sub TaskThreeProcess_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles TaskThreeProcess.Disposed
Call StartFixing()
End Sub
This is a over simplification of what's going on but it gets the point across. So it works exactly as expected, a button is pressed and the sequence starts. As each task gets disposed it recalls the StartFixing statement which then calls the next one in order until they are all done. BUT when I go to do it a second time the Disposed never fires assuming since it's already disposed. How do I recreate the same named process so it can be reused and still have it fire the disposed event?
-Allan