C#显示通知提示更新? [英] c# Show notification prompting a update ?

查看:118
本文介绍了C#显示通知提示更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想知道是否有可能让我的程序总是在后台寻找更新,就像总是在后台有一个应用在寻找更新,所以当我通过应用更新时,会弹出一个小提示,说有可用的更新 我的程序,因为当前我在程序启动时有一个消息框,我想在任务栏中像Java一样有一个图标,当我通过更新时,会弹出一个小提示,说有更新在等待?

Hello i was wondering is it possible to have my program always look for updates like in the background always have a app looking for updates so when i pass a application update there is a little notification that pops up saying there is a update available for my program because currently i have a message box when the program launches and i wanted to have a icon in the task bar like java and when i pass a update a little prompt pops up saying there is a update waiting ?

这是我要执行的操作的图片,但是如果单击通知,它将加载更新程序.

this is a pic of what i want to do but have it so if you click the notification it will load up the updater.

这是我目前用于检查更新的代码

and this is the code i have currently for checking for updates

 public void CheckForUpdates()
    {
        try
        {
            CleanUp();

            WebClient downloadClient = new WebClient();
            downloadClient.DownloadFile(UpdateUrl, LocalUpdateFile);
            downloadClient.Dispose();

            if (!File.Exists(LocalUpdateFile))
                throw new FileNotFoundException("The local update file is missing!", LocalUpdateFile);

            UpdateSaveFile localFile = DecodeSaveFile(LocalUpdateFile);

            Version localVersion = Assembly.GetEntryAssembly().GetName().Version;
            Version onlineVersion = Version.Parse(localFile.VersionString);

            if (onlineVersion > localVersion)
            {

                if (DevExpress.XtraEditors.XtraMessageBox.Show(String.Format("Version {0} available,\nInstall it now?", onlineVersion.ToString()), "Elfenliedtopfan5 BO3 Weapon Adder Updater.", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)//MessageBox.Show(String.Format("Version {0} available,\nInstall it now?", onlineVersion.ToString()), "Youtube Updater", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {

                    frmUpdater updateForm = new frmUpdater(localFile, GetPath(UpdateUrl));
                    updateForm.ShowDialog();
                }
            }
            else
            {
                Message_elf msg = new Message_elf("You already have the latest version!", "elfenliedtopfan5 weapon adder 2016");
                //MessageBox.Show("You already have the latest version!", "Youtube Updater", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        catch (Exception e)
        {
            MessageBox.Show("Error checking for updates\ntry again later!\n\nError Message:" + e.Message, "Youtube Updater", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }

我可以通过这样的主要形式调用它. updater1.CheckForUpdates();

and i can call it via my main form like this. updater1.CheckForUpdates();

任何帮助都非常合适.

any help would be much appropriated.

推荐答案

如果您的问题是要检查更新是否在后台"运行,则可以使用间隔为几分钟,然后将CheckForUpdates放入tick事件.
If your problem is getting the check for updates to run "in the background", you can use a Timer with an interval of, say, a few minutes and put CheckForUpdates in the tick event.


这篇关于C#显示通知提示更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆