you used the cross platform template and it does not support service events. You need to create a new console project (there is no template) and use ServiceBase to create the service callback.
Example
Typically when creating a service, you run the actual service code on a separate thread, you can also write as async. For example the onStop callback needs to be able to stop the service processing code, you can use a cancellation token for this.
Depending on you needs, you may also need to implement a ServiceProcessInstaller
Note: I’ve only written services in C/C++, but the above libraries look like thin wrappers around the o/s code.