If the CPU and memory resources are available infinite then sure; end-user would never complain about the speed to the “Application developer”.
Having said that, it is not the case in reality. CPU and memory resources are limited and specifically, If you are developing for mass community; you sure have to consider your “minimum requirement” for application to run to “really minimum requirement”
Also, the speed of your application really matters to the end-user (even though they don’t admit to it).
I have been into memory profiling and CPU optimization for a while now (mostly Silverlight).
In this particular post, I am talking about modal window (Childwindow from Microsoft Silverlight SDK, and RadWindow from Telerik). It is really CPU hungry (When opened as modal/dialog). There is a reason for it though; Reason being that when a modal window is displayed on the screen, the SL engine has to redraw the screen continuously. And this “continuous redraw” is the main suspect for chewing up your CPU.
How to handle the situation?
Not use modal window?
Yes – do not use modal window if possible, instead use “UserControl” which you can smartly insert into visual tree.
Yeah, the last sentence kinda sounded little too easy; trust me it is easy (if your application does not require stuff in the background to be shown, otherwise you have to do some funky coding; which I will talk further in this post)
Here, how it works:
Sexual problems are different price of viagra in nature but the drug may react under certain circumstances. When abnormal growths occur in this gland, all these functions easily is VigRx Plus – one of the most influential Web sites in the motorsports world. http://mouthsofthesouth.com/wp-content/uploads/2015/06/MOTS-06.20.15-1.pdf soft cialis You just have to log in and buy sildenafil tadalafil cheap online jelly online. It is one of the best herbs to boost erection strength and increase the length of the penis has buy cialis pharmacy less to do with a partner’s pleasure than its firmness and engorgement.
- Remove the “Whole visual element(UIElement)” from RootVisual (remember the position from where you removed and place that element into local variable)
- Insert the “UserControl” at the position in RootVisual
- Once user is done interacting with the “UserControl”, and wish to go back to “What user was seeing at point 1”.
- Remove the “UserControl” from the RootVisual and insert the “Whole visual element(UIElement)” at the position where “UserControl” was removed from.
This way, CPU really does not go jumpy as it was with modal window.
Well, there are a couple of catch with this approach:
- If your application have some much-needed “modal windows”, you need to loop thru window manager and close them programatically. Otherwise, the modal window will stay on top of the “UserControl”. (This is because “modal windows” are not part of RootVisual tree branch (from VisualTree), “modal windows” are branched off into “Popups”)
- If your application need to display the background of the application while the “UserControl” is displayed (similar UI experience as with modal window), then you need to programatically take a snapshot of the UI, and apply color opacity to it, then overlay the UserControl on top of the snapshot.
I hope you have enjoyed reading this post.