1

I have a Silverlight 5 application which communicates with the server by a WCF service.

Most users that use the application are running it inside a browser (mostly Internet Explorer, but also other browsers are used) and a few install it OOB (Out Of Browser).

When the application starts, It checks for newer versions and upgrade if necessarily. Nothing out of the ordinary here.

Now and then, mostly in evenings and weekends, I do upgrades on the solution. That may be changes in the database, changes in the WCF service, changes in the Silverlight application itself, or a mix of all. And in most cases, that is absolutely no problem.

My problem is that some users never close their web browser. Some users even work via a Citrix window, and only close the Citrix window and goes home after work, letting the Silverlight application run and exist in the web browser. And some just don't close the browser at all. Or if they run OOB, they let the application stay open. Those are my problem. Because they will never check for new updates. The Silverlight application will never upgrade, and also not fit to the new WCF service which may be upgraded.

That all makes the Silverlight applications crash and throw strange exceptions because the world around has changed.

Has anyone had similar problems and actually found a good solution?

I have tried:

  • Creating a Timer that resets at any keyboard- or mouse clicks and exits the application after a given period of time with no activity. But it seems like this timer sometimes don't count, like when dosconnected from RDP or Citrix session.

  • Checking for updates every time a certain control or window is showing. But that is not a good solution because all users may not use the same. It may also interrupt the user if they are working with something.

But they all seem to me like a little tacky work-arounds.

Any suggestions, anyone?

Mats Magnem
  • 1,375
  • 1
  • 10
  • 21

1 Answers1

0

Restarting the timer while the user is active does not make sense to me. What if they are active at the time an update is released? Surely it is better to be interrupted than for the app to fall over?

Better to run the timer on a fixed interval. It would call CheckAndDownloadUpdateAsync and prompt the user if a restart is required.

For the fringe cases where the timer doesn't run or a critical update is published between intervals, you could try executing your update logic in the App.Application_UnhandledException method. Just don't forget to mark the event as handled where you find there is indeed an update to install...

This way you should have complete coverage.


Edit: For In-Browser applications you only need to worry about when to refresh the page, as this can be enough to ensure the XAP is the latest.

Your timer could call some JavaScript to achieve this, but I think it would be better to simply trigger the refresh in the App.Application_UnhandledException event. You could write state to IsolatedStorage before hand if you really want to make this seamless.

Community
  • 1
  • 1
Silver Solver
  • 2,310
  • 1
  • 13
  • 19
  • I have done lots of research for this, and I have come to the same conclusion. I am already doing some handling in the Application_UnhandledException event, so I can just as well do some additional checks there. Not exactly what I had in mind. But again, I don't think there are any better solution available, and this solution will actuallt cover all issues I can think of. So thank you for a good answer :-) – Mats Magnem Jan 31 '13 at 13:45
  • Update: I have found that the "CheckAndDownloadUpdateAsync" method does not work in-browser mode. Only OOB. So there is no "clean" way of checking if there is a new version if ther user has not closed the browser (let's say during the night or weekend) and an update has been done meanwhile. Of course, I can check this in the "Applicaction_UnhandledException" event. But that don't seem to cover it in a way good enough. I can ask the service, but that also seems like a "hack"... – Mats Magnem Feb 16 '13 at 22:55