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

后端 未结 10 1532
梦谈多话
梦谈多话 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-05 10:43

    The most simple (and reliable) way to do this, is using a Mutex. Use the WaitOne method of the Mutex class to wait until the mutex becomes available. An added advantage, this will not require any infinite loops

提交回复
热议问题