22 July 2013

Metrostyle Dashboard



There was a requirement from a corporate client to create a metro style dashboard (don’t confuse with metro style apps) for there existing application created in WPF platform. When you say Metro Style Dash board it should looks like windows 8 looks like tile based user interface.
Good news is that Dev Express and Infragistics have already come up with controls that support Tile based metro style dashboards. Developers don’t need to re invent the tile based programming. Rather than come up with custom coding with high malignance and lots of coding we can experiment these cool features provided by DevExpress and Infragistics.
Dev Express – Dev Express Tile Layout Control provides a frame work where we can easily develop tile based UI with few line of code. Please check the link - http://documentation.devexpress.com/#WPF/CustomDocument10996
Infragistics - also has XamTilemanager with encapsulate most of the complexity of tile based development. We can have a nice tile managed UI with few line of code with dynamic loading and drag and drop functionalities. Please check the link -  
http://www.infragistics.com/community/blogs/atanas_dyulgerov/archive/2011/01/01/xamtilemanager-new-control-in-the-xaml-line-of-business-product-shipped-with-the-11-2-release.aspx

Weak References



I have not personally come across a situation where I've needed to use Weak Reference type in .Net, But while addressing a defect there was a scenario where UI is publishing an event and listen for the responses through event channel frame work built on hardware based java framework. Un fortunately the UI code for publishing the message was written on weak reference type (n later realised this was to address performance related issues)
Occasionally the frameworks that are subscribed to JIT events lose their subscription and stop receiving the events when it is published. The issue was due to the event aggregator that use for JIT publishing uses weak references for the subscribed events which can then be lost when Garbage Collection occurs.
The fix was simple, but to reach in to conclusion it was tough as this was not happening very often. The issue was fixed; basically remove all the weak reference from event aggregator subscription.
A Simple example to test weak reference is given below- 

        static WeakReference _weak;
        public void TriggerWeakRefernce()
        {
            // Assign the WeakReference.
            _weak = new WeakReference(new StringBuilder("eventtChannel"));
            // See if weak reference is alive.
            if (_weak.IsAlive)
            {
                var stringBuilder = _weak.Target as StringBuilder;
                if (stringBuilder != null)
                    Console.WriteLine(stringBuilder.ToString());
            }
            // Invoke GC.Collect.
            // ... If this is commented out, the next condition will evaluate true.
            GC.Collect();

            // Check alive.
            if (_weak.IsAlive)
            {
                Console.WriteLine("Event Channel is Alive");
            }
            // Finish.
            Console.WriteLine("[Done]");
            Console.Read();
        }