vb.net windows服务timer.elapsed事件未完成所有任务

时间:2017-06-15 17:55:19

标签: vb.net windows-services

此Windows服务会检查每分钟是否有待处理的待处理记录,一次检查测试站点,一次检查生产站点;我只有一个带有参数的子例程来指示测试站点是否使用了正确的SQL连接字符串。

我正在使用 Elapsed 事件调用子程序2次,但只调用第一个子程序。

代码:

{
Private Shared iMacrosExecuterTimer As Timers.Timer

    Protected Overrides Sub OnStart(ByVal args() As String)
        'Initiate and set timer
        iMacrosExecuterTimer = New Timers.Timer
        iMacrosExecuterTimer.Interval = 5000 '5 seconds so it start immediately after it gets enabled, then it will be called every minute
        AddHandler iMacrosExecuterTimer.Elapsed, AddressOf OnTimedEvent
        iMacrosExecuterTimer.AutoReset = False
        iMacrosExecuterTimer.Start()
    End Sub 'OnStart

    Protected Overrides Sub OnStop()
    End Sub 'OnStop

    Private Sub OnTimedEvent(source As Object, e As System.Timers.ElapsedEventArgs)
        iMacrosExecuterEventLog.WriteEntry("OnTimedEvent: S T A R T E D", EventLogEntryType.Information) 'added for testing purposes
        'Testing Site
        CheckPendingiMacros(True)

        'Production Site
        CheckPendingiMacros(False)
        iMacrosExecuterEventLog.WriteEntry("OnTimedEvent: E N D E D", EventLogEntryType.Information) 'added for testing purposes

        'Re-Start the service again
        iMacrosExecuterTimer.Interval = 60000
        iMacrosExecuterTimer.Start()
    End Sub

    Private Sub CheckPendingiMacros(ByVal TestingSite As Boolean)
}

0 个答案:

没有答案