long running tasks in viewmodel

Topics: Prism v4 - Silverlight 4
Feb 20, 2012 at 4:22 AM

Hi all,

How to process long running tasks in ViewModel of a module in prism in a thread different from UI. If I use UI thread, the UI are hanged and really annoying users.

I have been searching for this and find this post here: http://weblogs.asp.net/jimjackson/archive/2010/05/21/using-the-backgroundworker-in-a-silverlight-mvvm-application.aspx to suggest to use background thread. However, I don't know how to initialize and use background thread in prism framework.


Please help to share.



Feb 29, 2012 at 8:08 PM

Hi Truyenle,

As far as I know, there is no official guidance regarding the use of background workers in Prism as out of the box. However, after checking the article you mentioned, I believe you should be able to apply the concepts described in a Prism application without problems.

Based on my understanding, the only apparent different when using Prism would be that the view and view model would be resolved through the container. As this doesn't seem to interfere with the logic described in the aforementioned blog post you could use the same view and view model.

In the following link you can find a modified version of the Hello World Quickstart, which includes the code snippets provided in the aforementioned blog post, under the name Prism with BackgroundWorker.zip:

I hope you find this useful,

Damian Cherubini

Mar 1, 2012 at 2:58 PM

Thank youuuuuu! You save me a day.