Bonjour,
Je viens de creer mon premier Service Windows. Je me suis inspire du petit tutoriel sur ce meme site. Mon probleme c'est que mon service ce lance bien et ecrit "service started" dans le journal d'evenement, mais ensuite il ne fait plus rien... Jusqu'a ce que je l'arrete et qu'il m'ecrive "service stopped" dans le journal.
Si je resume, les evenements OnStart et OnStop sont bien appelles, en revanche l'evenement Tick de mon timer lui n'est jamais declenche.

Je poste mon code car il n'y a pas grand chose.
Merci

Code vb.net : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Public Class SMemory
 
  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.
    eventL.WriteEntry("service started")
    Timer1.Enabled = True
    Timer1.Start()
  End Sub
 
  Protected Overrides Sub OnStop()
    ' Add code here to perform any tear-down necessary to stop your service.
    eventL.WriteEntry("service stopped")
    Timer1.Enabled = False
    Timer1.Stop()
  End Sub
 
  Public Sub New()
    ' This call is required by the Windows Form Designer.
    InitializeComponent()
 
    ' Add any initialization after the InitializeComponent() call.
    'if the eventlog does not exists 
    If Not eventL.SourceExists("ServiceMemory") Then
      'create it
      eventL.CreateEventSource("ServiceMemory", "EventLogMemory")
    End If
    eventL.Source = "ServiceMemory"
  End Sub
 
  Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    eventL.WriteEntry("service running")
  End Sub
End Class