简体   繁体   中英

how to keep running C# application after windows log off

I wrote a C# application using RESTful web services. This application should interact periodically with our server application. I want this program to keep running in the background even if the user logs out of the computer. How can I do this in C#?

If you don't want your application to stop when the user logs out, then the application can't be running in the user's session (really a WinStation ). That implies your app needs to run in a different session. The sessions that don't logout are service sessions. Run Task Manager and add the Session ID column, and view all processes, and you'll see what I mean.

So your application needs to run as, or be launched by, a service.

In addition to the first answer don't keep the service running under the specific user account. If you do so then also it won't work if you logged off.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM