我完全是VB.net的新手,我试图运行一个半中级脚本,它检查某些文件是否被打开。当它首次打开时,它会检查一个特定的程序,然后在计时器上继续检查另一个程序。但是,当我运行代码时,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秒检查一次。 有什么想法吗?
Timer.Start()
方法,或者将Timer.Enabled
属性设置为True
。 - alldayremix1000 毫秒等于 1 秒
。 - spajce