Application.Restart() for WPF
Got a question from somebody today about what the corresponding API in WPF for Window Forms’s Application.Restart().
If my application detects a new version on the server, after successfully updating the application with System.Deployment.Application.ApplicationDeployment.CurrentDeployment.Update(), I get the functionality of Restart() for a WPF application by calling:
- System.Windows.Forms.Application.Restart(); //from System.Windows.Forms.dll
Why would one consider this…
When you use clickonce for publishing, you can:
- have clickonce check for a new version, before launching the current installed app.
- have clickonce check for a new version, after launching the current installed app.
- don’t have clickonce check at all, but use System.Deployment.Application.ApplicationDeployment APIs to check whenever you want.
If you use #2 or #3, you may want to restart (or offer to restart an app) if a new update was found…
I lean towards #2 or #3 since I don’t want to delay launching my application every time I launch the app…
(I’m not a total expert in this area…as always, please feel free to correct or add other info to help out readers…)