views:

101

answers:

2

During localhost testing of modular Prism-based Silverlight applications, the XAP modules download too fast to get a feel for the final result. This makes it difficult to see where progress, splash-screens, or other visual states, needs to be shown.

What is the best (or most standard) method for intentionally slowing down the loading of XAP modules and other content in a local development set-up?

I've been adding the occasional timer delay (via a code-based storyboard), but I would prefer something I can place under the hood (in say the Unity loader?) to add a substantial delay to all module loads and in debug builds only.

Suggestions welcomed*

*Note: I have investigated the "large file" option and it is unworkable for large projects (and fails to create XAP with really large files with out of memory error). The solution needs to be code based and preferably integrate behind the scenes to slow down module loading in a local-host environment.

**Note: To clarify, we are specifically seeking an answer compatible with the Microsoft PRISM pattern & PRISM/CAL Libraries.

A: 

You could simply add huge files (such as videos) to your module projects. It'll take longer to build such projects, but they'll also be bigger and therefore take longer to download locally. When you move to production, simply remove the huge files.

SirDemon
I had considered large files, but it seemed far too wasteful of time and space. They would need to be really huge to take 5-10 seconds to download from a local hard drive. Thanks though
Enough already
Actually, I just watched a tutorial about changing the splash screen of silverlight apps yesterday, a file of about 120mb was enough to delay the download to about 5 or 6 seconds so you could see the load up splash screen.
SirDemon
Physically adding a large file, to one module alone, tied up VS 2010 for a long time (and resulted in an out-of-memory exception while building the XAP file!). I will keep looking for a nice code-based option as I have many dozens of modules to apply this to (only while running locally). Thanks anyway
Enough already
XAPs can be loaded asynchronously in the background, so I'm not sure where you need all this progress personally. If you're using PRISM then your XAPs should be of a manageable size. Are you using delayed loading? On Demand? When Available?
kmacmahon
A: 

Do not add any files to your module projects. This adds unnecessary regression testing to your module since you are changing the layout of the module by extending the non-executable portion. Chances are you won't do this regression testing, and, who knows if it will cause a problem. Best to be paranoid.

Instead, come up with a Delay(int milliseconds) procedure that you pass into a callback that materializes the callback you use to retrieve the remote assembly.

In other words, decouple assembly resource acquisition from assembly resource usage. Between these two phases insert arbitrarily random amounts of wait time. I would also recommend logging the actual time it took remote users to get the assembly, and use that for future test points so that your UI Designers & QA Team have valuable information on how long users are waiting. This will allow you to cheaply mock-up the end-user's experience in your QA environment. Just make sure your log includes relevant details like the size of the assembly requested.

I posed a question on StackOverflow a few weeks ago about something related to this, and had to deal with the question you posed, so I am confident this is the right answer, born from experience, not cleverness.

@user429921: The key to this question is that *we are using PRISM*. That means we already have all the separation-of-concerns we could possibly wish for. We are after a solution that integrates well with the existing Microsoft CAL layer and enables us to view transitions that only take a split second when run locally. The answer will need to be PRISM compatible/aware/compliant to be acceptable. Thanks
Enough already
@HiTech Magic: There is a reason I DON'T recommend using Prism :), but some quick Googling pointed me towards an article that will allow you to implement my advice: http://wildermuth.com/2009/07/20/Prism_s_Plugin_Architecture It is from Jul 29, 2009, so hopefully the API Shawn Wildermuth uses matches your current Prism version #'s API.
@user429921: don't knock Prism without suggesting a better alternative :) I will investigate the link you provided in detail tomorrow. Looks interesting. We are using the latest Alpha of Prism 4, but we can usually figure out the changes from older how-to-guides. Thanks
Enough already
@HiTech Magic: So what is the verdict? Could your team figure out how to subclass a few Prism extension points?
In the absence of any complete answers, you get the bounty. I will offer larger bounties in future (as the Silverlight area of StackOverflow is very quiet). Thanks for your suggestions :)
Enough already