Reputation: 2153
at the moment my application updates perfectly before the application starts. If there's a new version, the prompt will appear. Some of my clients will not restart the program, they simply would log-out and leave it running in the background. How can I set up clickonce to have the program update before application is running and check for updates every 4 hours.
I can see there's two options in Application Updates - After application starts and before application starts. But I'm looking for something that's a combination of both.
Upvotes: 0
Views: 415
Reputation: 7301
I have implemented this the following way:
public void StartSearchForUpdates()
{
if(!ApplicationDeployment.IsNetworkDeployed)
{
return;
}
bool updateAvailable = false;
Task.Run(async () =>
{
while (!updateAvailable)
{
await Task.Delay(TimeSpan.FromHours(4));
updateAvailable = ApplicationDeployment.CurrentDeployment.CheckForUpdate();
if (UpdateAvailable)
{
ApplicationDeployment.CurrentDeployment.UpdateAsync();
ApplicationDeployment.CurrentDeployment.UpdateCompleted += OnUpdatedCompleted;
}
}
});
}
private void OnUpdatedCompleted(object sender, AsyncCompletedEventArgs e)
{
AvailableVersion = ApplicationDeployment.CurrentDeployment.UpdatedVersion;
}
Upvotes: 3
Reputation: 187
There's no way to do it with click once.
I suggest you to create a background thread in your app that check if there is a new version of the app...
Upvotes: 2