以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  如何禁止开启2个程序  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=122824)

--  作者:lur320
--  发布时间:2018/8/2 16:47:00
--  如何禁止开启2个程序
有时开启同一个程序2次,会导致1个程序里面的数据错误,
请问如何禁止?

另外如果开发了2个不同的程序,每个只能运行1个,可以么?上面的禁止是禁止狐表的进程?还是区别不同的发布程序单独禁止?

--  作者:lur320
--  发布时间:2018/8/2 16:55:00
--  
找到了
static mu As System.Threading.Mutex
Dim sucess As Boolean = False
mu = new System.Threading.Mutex(True, "v123123tem", sucess)
If not sucess Then
    MessageBox.Show("系统已经在运行,系统不支持重复开启!","重要提示",MessageBoxButtons.Ok,MessageBoxIcon.Error, 0, Windows.forms.MessageBoxOptions.ServiceNotification)
    e.Cancel = True
End If