Nirav's Blog

Friday, December 18, 2009

WPF Multi Threading : Display loader using a separate thread while downloading data from remote server

I came across a problem while developing an application.
On click of a button I need to download some data from a remote server using web service. Once I start downloading data, I was required to show loader animation on the screen. Because the data I was downloading were huge, the application was getting stuck. With this situation the loader animation was not getting displayed on the screen. In such scenario, user has no clue about what happened with the application. The reason for this was the huge data being downloaded from the application and all these was performed in single thread.
I want loader animation to keep displaying in such scenarios। To achieve this I created a new thread which downloads data from the remote server. So even if there is some additional pain to one thread, it does not make other thread down. So with loader animation and data download happened in separate threads, both the operations remains intact. With this approach I can display loader animation without getting affected by the other thread which is downloading data from remote server.


Download Sample Code from here: http://cid-cd9cdbf38105503c.skydrive.live.com/self.aspx/Blog%20Posts/WpfMultiThread.zip

Microsoft Silverlight 4 Beta

With the release of Silverlight 4 beta, Microsoft has provided some excellent features which make silverlight more suitable for business applications.
Tim Heuer has a very good post on his blog about all these features.
http://timheuer.com/blog/archive/2009/11/18/whats-new-in-silverlight-4-complete-guide-new-features.aspx
As per my opinion the most impressive features are: enhanced capabilities of Out-Of-Browser applications which can access local machine assets and Multi-touch capabilities.
With Silverlight 4 Beta you can develop an application which can access local file system, access web cam and printer, run Office applications etc. More tooling support is available as well with Visual Studio 2010 Beta.
There are many more enhancements provided with Silverlight 4 Beta. You can get detailed information about all of them at http://silverlight.net/getstarted/silverlight-4-beta/