mardi 24 mars 2015

vb.net checking process is ended, and modify the UI

I have a problem, my program (when launched the process) minized into system tray, and when the process ended, it shows in normal state, but its not working with my solution, i get this error message:



An unhandled exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll


My code:



Dim p as new Process
p.filename = "somefile.exe"
p.workingdirectory = "somepath"
p.EnableRaisingEvents = True
AddHandler p.Exited, AddressOf Main.Main_Process_Closed
p.Start()


The handler in the main form:



Public Sub Main_Process_Closed(ByVal sender As Object, ByVal e As System.EventArgs)
Me.Visible = True
Me.WindowState = FormWindowState.Normal
NotifyIcon1.Visible = False
End Sub


But what is the problem? Thanks for help.


Aucun commentaire:

Enregistrer un commentaire