웹 데이터베이스에서 일부 데이터를 읽고 주기적으로 로컬 데이터베이스를 업데이트하는 응용 프로그램이 있습니다. 매 5 분마다 말하십시오.타이머가 Windows 서비스 응용 프로그램에서 실행되고 있지 않습니다.
이것은 대화식 Windows 응용 프로그램의 형태입니다. 그러나이 응용 프로그램이 지속적으로 실행되어야하므로 Windows 서비스 응용 프로그램을 만들기로 결정했습니다.
우리는 응용 프로그램에서 5 분 간격으로 설정된 타이머를 사용했으며 타이머의 모든 틱에서 웹 업데이트를 확인했습니다.
우리도 같은 일을했습니다. 그러나 타이머가 지금 작동하지 않는 것 같습니다. 다음은 서비스의 몇 가지 방법입니다.
Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
'connect to sap business one
If Connect("rlap1", "sa", "dracula", "UnimaxNew", "manager", "manager") = False Then
End
SyncEvents.WriteEntry("Unable to connect to SAP Business One, " & oCompany.GetLastErrorDescription, EventLogEntryType.Error)
Else
SyncEvents.WriteEntry("Connected to SAP Business One.", EventLogEntryType.Information)
End If
'start the timers
WebTimer.Start()
SapTimer.Start()
DataTimer.Start()
SyncEvents.WriteEntry("Synchronization process started.")
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
oCompany.Disconnect()
SyncEvents.WriteEntry("Disconnected from SAP Business One.", EventLogEntryType.Information)
'stop the timers
WebTimer.Stop()
SapTimer.Stop()
DataTimer.Stop()
SyncEvents.WriteEntry("Synchronization process stopped.")
End Sub
Private Sub WebTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WebTimer.Tick
SyncEvents.WriteEntry("Checking for new orders.")
CheckOrder()
End Sub
Private Sub SapTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SapTimer.Tick
SyncEvents.WriteEntry("Checking for new deliveries.")
CheckDelivery()
End Sub
Private Sub DataTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataTimer.Tick
SyncEvents.WriteEntry("Checking for stock updates.")
CheckStock()
End Sub
서비스가 시작되거나 중지 될 때 메시지가 올바르게 기록됩니다. 그러나 타이머 기능의 메시지는 없습니다. 또한 Visual Studio에서 Attach To Process ..를 사용하여 서비스 디버깅을 시도했습니다. 그러나 심지어 코드가 틱 기능 중 하나에서 중단되지 않았습니다.
서비스에서 타이머를 사용할 수 없습니까? 그렇지 않다면, 다른 방법보다. 그렇다면 여기서 무엇이 잘못 될 수 있습니까?
감사 라훌자인 Windows 서비스에서 작동 타이머를 방지 거기에 아무것도