以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  禁止重复打开项目导致升级出错的问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=123407)

--  作者:happyft
--  发布时间:2018/8/14 9:11:00
--  禁止重复打开项目导致升级出错的问题
在beforeopenproject中用了如下事件代码:
\'---控制一台电脑只能打开一个客户端运行!
Dim sucess As Boolean = False
mu = new System.Threading.Mutex(True, "dsdfhdfghf", sucess)
If not sucess Then
    MessageBox.Show("程序已经在运行,不能重复打开!", "提示",MessageBoxButtons.Ok,MessageBoxIcon.Warning,0, Windows.forms.MessageBoxOptions.ServiceNotification)
    e.Cancel = True
End If

在afterOPenproject中的升级代码如下:
If ftp.Download("\\Update\\Update1.Zip",Path & "\\Update1.Zip",True) = True Then  \'小版本升级
    UpdatePath =  Path
    RemoteUpdate = False
    If Syscmd.Project.Update(False,False) = True Then \'发现新版本时不提示用户,因为前面已提示过
        Application.restart  \'重新启动
        \'Return \'小版本更新不用返回,否则升级完成后不能自动打开程序
    End If
End If

小版本升级上面红色代码重启后就会出现上面的"程序已经在运行,不能重复打开!" 出错,导致打开项目终止,关掉错误,再次重新打开项目又可正常使用。
应该如何避免这个问题?

谢谢!

--  作者:有点甜
--  发布时间:2018/8/14 10:23:00
--  

结束一下,再重启

 

mu.close

Application.restart  \'重新启动


--  作者:lianghanyu
--  发布时间:2020/8/4 8:28:00
--  

为什么我复制代码后,显示:未声明 MU 

然后我这样改:

Dim sucess As Boolean = False
Dim mu = new System.Threading.Mutex(True, "dsdfhdfghf", sucess)
If not sucess Then
    MessageBox.Show("程序已经在运行,不能重复打开!", "提示",MessageBoxButtons.Ok,MessageBoxIcon.Warning,0, Windows.forms.MessageBoxOptions.ServiceNotification)
    e.Cancel = True
End If

 

 

结果显示:编译错误,forms 不是windows成员


--  作者:lianghanyu
--  发布时间:2020/8/4 8:52:00
--  

Dim sucess As Boolean = False
Dim mu = new System.Threading.Mutex(True, "dsdfhdfghf", sucess)
If not sucess Then
    MessageBox.Show("程序已经在运行,不能重复打开!", "提示",MessageBoxButtons.Ok,MessageBoxIcon.Warning,0, system.Windows.forms.MessageBoxOptions.ServiceNotification)
    e.Cancel = True
End If

 

这样写了以后,还是可以打开两个啊?????????????????????为什么?????????????
图片点击可在新窗口打开查看此主题相关图片如下:qq图片20200804084633.gif
图片点击可在新窗口打开查看


--  作者:有点蓝
--  发布时间:2020/8/4 9:19:00
--  
static mu As System.Threading.Mutex
Dim sucess As Boolean = False
mu = new System.Threading.Mutex(True, "aaabbbccc", sucess)
If not sucess Then
    MessageBox.Show("系统已经在运行,请退出后重新登录!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    e.Cancel = True
End If