X# is very well suited for Windows Services. A Windows Service is a GUI less application that runs in the background of any Windows machine, and even without any logged in user. Therefore services are well suited for background tasks.
The .NET Framework has a base class for all Windows Services: the
ServiceBase class from the
System.ServiceProcess namespace: https://docs.microsoft.com/en-uk/dotnet/api/system.serviceprocess.servicebase
The X# code is very simple:
class XsharpService inherit ServiceBase constructor() super() self:InitializeComponent() return virtual method InitializeComponent() as void self:ServiceName := "Xsharp Service" self:EventLog:Log := "Application" // These Flags set whether or not to handle that specific // type of event. Set to true if you need it, false otherwise. self:CanHandlePowerEvent := false self:CanHandleSessionChangeEvent := false self:CanPauseAndContinue := true self:CanShutdown := true self:CanStop := true return protected virtual method OnStart( args as string ) as void super:OnStart( args ) return protected virtual method OnStop() as void super:OnStop() return protected virtual method OnPause() as void super:OnPause() return protected virtual method OnContinue() as void super:OnContinue() return protected virtual method OnTimeOut( oSender as object, e as ElapsedEventArgs ) as void return
You can find a complete working sample as XIDE export file here: xsharpservice.zip