为什么主界面会没有响应啊
程序是这样的:
Private Sub MenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mn_NotesStart.Click
Dim oConfig As New SMSClass.CConfig
Dim iInterval As Integer
oConfig.ConfigFile = "SMSCenter.exe.config"
mNotes.ServerName = oConfig.GetKeyValue("Notes_ServerName")
mNotes.DBName = oConfig.GetKeyValue("Notes_DBName")
Try
iInterval = CType(oConfig.GetKeyValue("Notes_ScanInterval"), Integer)
Catch ex As Exception
MsgBox("Notes 扫描时间不正确,请重新设置!", MsgBoxStyle.Exclamation)
Exit Sub
End Try
If mNotes.Init() Then
mn_NotesStart.Enabled = False
mn_NotesStop.Enabled = True
'开新的Notes发送线程
NotesThread = New System.Threading.Thread(AddressOf mNotes.NotesProc)
NotesThread.IsBackground = True
NotesThread.Start()
mbStartNotes = True '表示启用Notes服务,Timer2_Tick 中使用
Timer2.Interval = iInterval * 1000
Timer2.Start()
MsgBox("Notes短信服务已经启动!", MsgBoxStyle.Information)
Else
MsgBox("无法启动Notes短信服务,请检查Notes的环境配置!", MsgBoxStyle.Exclamation)
End If
End Sub
Private Sub mn_NotesStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mn_NotesStop.Click
Timer2.Stop()
mbStartNotes = False '服务停止
If mNotes.UnInit() Then
mn_NotesStart.Enabled = True
mn_NotesStop.Enabled = False
MsgBox("Notes短信服务已经停止!", MsgBoxStyle.Information)
Else
MsgBox("终止Notes短信服务出现错误!", MsgBoxStyle.Exclamation)
End If
End Sub
按钮触发这个函数后,主界面就没响应了
timer(定时器)是这样的:
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If Not mbStartNotes Then
Exit Sub
End If
Timer2.Stop()
If (NotesThread.ThreadState = Threading.ThreadState.Stopped) Then '如果线程执行完毕则激活新的Notes发送线程
NotesThread = Nothing
NotesThread = New System.Threading.Thread(AddressOf mNotes.NotesProc)
NotesThread.IsBackground = True
NotesThread.Start()
End If
If (NotesThread.ThreadState = Threading.ThreadState.Suspended) Then '如果已挂起则唤醒
NotesThread.Resume()
End If
Timer2.Start()
End Sub