Rem. Module de servive effecteur de tâches des objets Planification.
' NE PAS UTILISER EN PROGRAMMATION APPLICATIVE.
Option Explicit
Private TPlanifications() As Planification, Idt As Long
Public Sub DéplanifierTout()
Dim P As Long, M As Long
On Error Resume Next: M = UBound(TPlanifications): If Err Then Exit Sub
On Error GoTo 0
For P = 1 To M: Idt = Idt Mod M + 1
If Not TPlanifications(Idt) Is Nothing Then TPlanifications(Idt).Annuler
Set TPlanifications(Idt) = Nothing: Next P
End Sub
Public Function IdtPlanificationLancée(ByVal Source As Planification) As Long
Dim P As Long, M As Long
On Error Resume Next: M = UBound(TPlanifications): If Err Then ReDim TPlanifications(1 To 1): M = 1
On Error GoTo 0
For P = 1 To M: Idt = Idt Mod M + 1
If TPlanifications(Idt) Is Nothing Then Exit For
Next P
If P > M Then ReDim Preserve TPlanifications(1 To P): Idt = P
Set TPlanifications(Idt) = Source
Application.OnTime Source.HeureOT, "'XPlanificateur.OnTimeJoue " & Idt & "'"
IdtPlanificationLancée = Idt
End Function
Public Sub AnnulerPlanification(ByVal Idt As Long)
On Error Resume Next
Application.OnTime TPlanifications(Idt).HeureOT, "'XPlanificateur.OnTimeJoue " & Idt & "'", Schedule:=False
Set TPlanifications(Idt) = Nothing
End Sub
Private Sub OnTimeJoue(ByVal Idt As Long)
On Error Resume Next
TPlanifications(Idt).Actionner
Set TPlanifications(Idt) = Nothing
End Sub