Hi guys,
Instead of using a .cmd file and programming to launch after xx processes, can I launch my form (Reboot form) after all other processes........
Printable View
Hi guys,
Instead of using a .cmd file and programming to launch after xx processes, can I launch my form (Reboot form) after all other processes........
And again, in English ..... ?
What? it's in full english and clear...
@dun, u no my project from b4, so all the installer files, i'm starting in the app as a process, now can I launch my reboot form after all processes finish?
Hmm, it's English but not as we know it, Jim! Anyway, to track processes ....
vb.net Code:
Dim WithEvents p As New Process With {.EnableRaisingEvents = True} Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load AddHandler p.Exited, AddressOf ProcessExit p.StartInfo = New ProcessStartInfo("notepad") p.Start() End Sub Private Sub ProcessExit(sender As Object, e As System.EventArgs) MsgBox("Notepad gone bye-bye") End Sub
I no how to start, stop and track, i'm launching 30+ proceess 1 after other, so how to showw reboot form after all finished.......?
Using the Exited events. Link all the processes to a single handler and use the sender variable to identify which have exited. Once all the processes you started are accounted for then open the form.
Yay u understood, now can u help me do that, like I said i've no clue......
It looks like Dunfiddlin provided an example of the Exited event: AddHandler p.Exited, AddressOf ProcessExit. To use the sender variable, use DirectCast or CType.
I do apologize m8's but i need to check if all process exited/??
Really i have no clue......
I'm making the following assumption:
U no how 2 tr4nsl8 2 VB :)Gr8, give r8ings m8.Code:sub S()
4 x = 0 2 apps.length -1
d1m p = new proc with {.EnableRaisingEvents = tru}
+Handler p.Xited, +dressOf Yo
p.St4rt1nfo = new ProcessStartInfo(apps(x))
p.Start
nXt
end sub
sub Yo()
static c as int =0
c+=1
if c = apps.length then
doIt
end if
end sub
vb.net Code:
Public Class Form1 ' We'll assume you have all the filepaths in a listbox ' it would work the same for any other collection type Dim pCount As Integer Dim p() As Process Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click 'launch pCount = ListBox1.Items.Count ReDim p(pCount - 1) For i = 0 To pCount - 1 p(i) = New Process With {.EnableRaisingEvents = True} AddHandler p(i).Exited, AddressOf ProcessExit p(i).StartInfo.FileName = ListBox1.Items(i).ToString p(i).Start() Next End Sub Private Sub ProcessExit(sender As Object, e As System.EventArgs) pCount -= 1 If pCount = 0 Then MsgBox("All Done") End If End Sub End Class
haha sorry don't understand Joacim lol
@dun, here's my install form, as u see no listbox, reads straight from .ini:Don't worry, the stuff we/you did yesterday is in select app form :)Code:Public Class InstallPrograms
Dim file_name As String = "./Start/InstallCFG.ini"
Dim stream_reader As New IO.StreamReader(file_name)
Dim line As String
Dim ReadResult() As String
Sub Form1_KeyUp(ByVal sender As Object, ByVal e As KeyEventArgs) Handles MyBase.KeyUp
If e.KeyData = Keys.F1 Then
Editor.ShowDialog()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
line = stream_reader.ReadLine() 'Read InstallCFG.ini File
Do While Not (line Is Nothing)
ReadResult = line.Split(":") 'Split line at :
If (ReadResult(0).ToLower() = "prog name") Then
Label3.Text = "Installing " + ReadResult(1)
End If
If (ReadResult(0).ToLower() = "installer file") Then
PictureBox1.ImageLocation = ".\images\System-Working.gif"
Label3.Refresh()
Label5.Refresh()
Dim info As New System.Diagnostics.ProcessStartInfo
info.FileName = ReadResult(1) 'Open the application
Dim myProcess As New System.Diagnostics.Process
myProcess.StartInfo = info
myProcess.Start() 'Start the process
myProcess.WaitForExit() 'Wait until the process started is finished
myProcess.Close() 'Release the resources
Label5.Text = "Install Complete..."
Label5.Refresh()
System.Threading.Thread.Sleep(750)
Label5.Text = ""
Label5.Refresh()
Else
MessageBox.Show("Something is wrong! File = " & ReadResult(1))
End If
line = stream_reader.ReadLine() 'Move on to the next line.
Loop
stream_reader.Close()
End Sub
End Class
Anyone can help me sort it?