jimmygoska
Member
- Joined
- Apr 12, 2010
- Messages
- 5
- Programming Experience
- Beginner
Hey,
I'm pretty new to VB and have had a lot of trouble with this program i'm writing. The problem that I'm encountering right now is that I can't seem to get my program to wait for a couple seconds for another application to load before it starts to check if it's open. Here's what I've got (feel free to tell me its a terrible way of writing!):
ProcessesRunning is a function that just checks the existance of a process called "oasicer".
So if I don't have the sleep function then oasicer hasn't loaded and it says it's finished straight away, but if I call a 5s sleep then it crashes, and not for just 5 sec. Is there a replacement for this line? Something that would just delay going to the while loop?
Any help is greatly appreciated!
Thank you for your time!
I'm pretty new to VB and have had a lot of trouble with this program i'm writing. The problem that I'm encountering right now is that I can't seem to get my program to wait for a couple seconds for another application to load before it starts to check if it's open. Here's what I've got (feel free to tell me its a terrible way of writing!):
VB.NET:
Private Sub Running_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
Main.Enabled = False
ProgressBar1.Style = ProgressBarStyle.Marquee
Dim path As String = System.Environment.CurrentDirectory
Dim yes As String = "cmd /K CD " & path & "\OASIC & oasicer hammer_8_8.txt"
Dim fullpath As String = path & "\OASIC\oasicer.exe"
Shell(yes, AppWinStyle.NormalFocus)
System.Threading.Thread.Sleep(500) <--------- This is the problem
Dim ProgramRunning As Boolean = True
While ProgramRunning = True
If ProcessesRunning("oasicer") = 1 Then
ProgramRunning = True
ElseIf ProcessesRunning("oasicer") = 0 Then
ProgramRunning = False
MessageBox.Show("It's closed!", "Done", MessageBoxButtons.OK) ' = Windows.Forms.DialogResult.OK Then Me.Dispose()
End If
End While
End Sub
ProcessesRunning is a function that just checks the existance of a process called "oasicer".
So if I don't have the sleep function then oasicer hasn't loaded and it says it's finished straight away, but if I call a 5s sleep then it crashes, and not for just 5 sec. Is there a replacement for this line? Something that would just delay going to the while loop?
Any help is greatly appreciated!
Thank you for your time!