0

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 notification

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.

Marc
  • 3,905
  • 4
  • 21
  • 37
  • Have you looked into this http://stackoverflow.com/questions/11027051/how-to-develop-a-program-that-runs-in-the-background-in-net ? – vipersassassin Dec 19 '16 at 22:48

1 Answers1

0

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.

pizzaslice
  • 478
  • 2
  • 8
  • that sounds like a good idea ;) but only issue i have there is how will i link that to the code i have above as i done that in a update.cs and no form in that cs so i not sure how i can get that to work. – elfenliedtopfan5 Dec 19 '16 at 23:16
  • You could pass in arguments to your app when it's run, check for that argument, and if it's only an update call don't display the UI only display in the task bar and toast if an update received; myapp.exe -update – pizzaslice Dec 19 '16 at 23:20
  • mmmm that could work i would have to find the best way of doing it though it was a very long time since i touched on this so a little rusty but have to look into it – elfenliedtopfan5 Dec 19 '16 at 23:34