I know how to creat windows services in Net, but how to do it using UWP, I want the service can run it automatically and we can stop it if we want.
You cannot create a traditional Windows Service using the UWP platform. However, you can create a an App Service that uses a Background Task. You can communicate between an app and your UWP App Service using a defined API surface much like a web service. I've included links below with more information.
Create and consume an app service
10 people are following this question.