i know this question is a bit subjective.. but i am basically looking to see if there is a better way of doing this than what i came up with.
i have a basic MVVM setup, where a treeview is bound to a tree structure.
this structure has nodes that load on demand.
when i expand a node, i fire off a command behavior, in this behavior, i query the necessary data, and add it to the node.
my first instinct is to use a background worker (within command behavior event), to which i pass the id of the node i am expanding. upon completion, the worker will find that node, and append it’s children.
This is an approach i inherited from winforms development. Curious if there is a better architectural solution for this.
We currently use the Task Parallel Library (TPL) because it makes it easier to pass data to the method to execute and makes your code look more like a typical synchronous method which is usually easier to read and understand. It also gets you closer to the async and await style of coding which will be coming with .NET 4.5 and is really important for Windows 8 programming.