c# 显示提示更新的通知? [英] c# Show notification prompting a update?
问题描述
你好,我想知道是否有可能让我的程序总是像在后台总是有一个应用程序在寻找更新一样,所以当我通过应用程序更新时,会弹出一个小通知,说有可用的更新对于我的程序,因为目前我在程序启动时有一个消息框,我想在任务栏中有一个像 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 ?
这是我想做什么的图片通知
这是我目前用于检查更新的代码.
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);
}
}
我可以像这样通过我的主表单调用它.
and i can call it via my main form like this.
updater1.CheckForUpdates();
任何帮助都会非常合适.
any help would be much appropriated.
推荐答案
与其创建一个服务并让那个东西一直在后台运行——现在很多公司所做的是创建一个任务调度程序任务安装过程.该任务调度程序进程不时运行以检查更新,您可以在此实用程序中构建任务栏 UI 组件,该组件在它运行时显示,并在更新可用时在屏幕截图时显示toast"通知.
Rather than create a service and have that thing running all the time in the background -- what a lot of companies do now is create a task scheduler task during the installation process. That task scheduler process runs every now and then to check for an update and you could build in a taskbar UI component to this utility that shows up while it's running and displays a "toast" notification as you screenshot when an update is available.
这篇关于c# 显示提示更新的通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!