Sub Service_Create
'some code............'
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS
Service.AutomaticForegroundNotification = CreateNotification("xxx" ,"my service","main",False,False)
Service.StartForeground(0, Notification1)
' start the main service task here: do something and send/cancel notifications if needed
End Sub
Sub Service_Destroy
'...............'
Service.StopAutomaticForeground
End Sub