私は VB.net をまったく初めて使用し、特定のファイルが開いているかどうかをチェックする半中間スクリプトを実行しようとしています。最初に開くと、特定のプログラムをチェックし、タイマーで別のプログラムをチェックし続けます。コードを実行すると、Sub Timer1 は実行されません。20 秒ごとに実行するように設定しています。
Imports System.Net
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If (Process.GetProcessesByName("PROGRAM1").Length >= 1) Then
MessageBox.Show("This Client is already running!", "IG Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
Environment.Exit(0)
Else
Process.Start(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "program.exe"))
'''' OPEN PROGRAM ABOVE ''''
End If
For Each frm As Form In Application.OpenForms
frm.WindowState = FormWindowState.Minimized
Next frm
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If (Process.GetProcessesByName("PROGRAM2").Length >= 1) Then 'CHECK FOR PROGRAM
MessageBox.Show("Program is running!", "IG Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
Environment.Exit(0)
Form3.Show()
Else
MessageBox.Show("Program is not running!")
End If
End Sub
End Class
上記は私が既に持っているコードです.私のタイマーサブは実行されていないか、20秒ごとにチェックしていません. 何か案は?