How to determine if a previous instance of my application is running?

后端 未结 10 1498
梦谈多话
梦谈多话 2020-12-05 10:31

I have a console application in C# in which I run various arcane automation tasks. I am well aware that this should really be a Windows Service since it nee

10条回答
  •  攒了一身酷
    2020-12-05 10:55

    You can search process names of existing system process. For example code, see this blog post.

    You can also used a named system Mutex to see if your process is already running.
    Here is some sample code. This tends to be more reliable in my experience, and is much simpler, more understandable code.

提交回复
热议问题