向不是来自应用程序的用户发出消息

时间:2011-12-14 16:12:24

标签: c# winforms

我们有两个应用程序。

  1. Main.exe - 正在更新的主要应用程序
  2. Update.exe - 运行以更新Main.exe的程序
  3. 我的问题是阻止用户在更新时进入main.exe。

    现在,我正在检查一个标志文件,如果标志文件存在,立即执行application.exe。

    这很好,除非它没有告诉用户什么,只是将它们踢出去。

    我要发出一条消息,它们响应消息所需的时间,main.exe正在使用中,无法更新。

    有关我如何能够专业地显示正在进行更新,应用程序关闭的消息的任何建议吗?

    不过,我想过要用:

    Private Function IsUpdatingPropane() As Boolean
        Try
            Dim UpdateInprocess As String = My.Computer.FileSystem.GetParentPath(Application.StartupPath) & "\update.inprocess"
            If File.Exists(UpdateInprocess) Then
    
                'Dim Proc As Process
                'Dim ProcInfo As New ProcessStartInfo(Configuration.DataFileLocations & Configuration.GasLibrary & "\vbmsg.exe")
                'ProcInfo.Arguments = String.Format("vbmsg.txt,{0},{1},NIL,NIL,NIL,OK,9996,9997", Configuration.UserId, Configuration.WorkstationId)
                'ProcInfo.WindowStyle = ProcessWindowStyle.Normal
                'ProcInfo.WorkingDirectory = Configuration.DataFileLocations & Configuration.GasLibrary
                'ProcInfo.UseShellExecute = False
                'Proc = Process.Start(ProcInfo)
    
    
                Application.Exit()
                Return True
            End If
            Return False
        Catch ex As Exception
            WriteException(ex)
            WriteDebugInfo("VerifyNotUpdatingPropane", "An error occurred while checking for update.inprocess file. Please contact SSS for assistance.", True, ex)
            Return True
        End Try
    End Function
    

    但是我打电话来显示消息?

    提前致谢!

2 个答案:

答案 0 :(得分:1)

此问题有几种可能的解决方案,包括:

  1. 创建一个简单的引导程序,检查标志文件,如果它不存在,则启动main.exe。否则会提示用户您的错误。这只有在您不必更新boostrapper时才有效。

  2. 使用AppDomain卷影副本允许用户在更新时访问您的应用程序,然后在完成后提示他们重新启动,更新的文件将覆盖“活动”应用程序。

答案 1 :(得分:1)

考虑我们的数据

  1. Main.exe
  2. Updater.exe
  3. 来自Main.exe的更新请求Main.exe启动Updater.exe结束自杀。 Updater.exe做到了。要在用户再次点击Main.exe时解决通知问题,您可以使用一些特殊参数启动Updater.exe的第二个实例,该实例会显示消息并退出Main.exe 。在这种情况下,即使用户暂时不关闭通知对话框(咖啡暂停),您也将拥有当代内存 2 Updater.exe的实例。一个是更新,第二个只是显示消息,一次消息关闭离开内存。

    简而言之,在Updater.exe内部移动消息可视化,仅在存在特殊命令行参数的情况下才会出现。

    希望这有帮助。