• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

Restarting while displaying data

I've got a bit of an architecture question here that I am having trouble wrapping my arms around.  I have a form with a treeview on the left and a datagridview on the right.  When the user highlights a node on the treeview, it populates the datagridview on the right with detail information.  This process of retrieving and populating the detail information may take a while (up to 20 seconds).

If, while loading the data, the user clicks a different node, I'd like to cancel the current retrieval process and start with the new one.  

What is the best way of doing this?  A backgroundworker?  Some other method?  What's the best way of telling the first process to stop and then to start the second process.  I'm assuming I'd need to wait for the first process to completely finish up so that I have a clean datagridview, etc.

Any thoughts on how best to handle this?  Are there any samples on the net that I missed?

Thanks,
Chris
0
chlade
Asked:
chlade
1 Solution
 
melmersCommented:
I think you should create a new worker thread for data retrivial and fire an event if the data lookup is finished. In your main application consume this event with an eventhandler and update your form. If the user clicks on another node in the treeview abort the worker thread.

If the user uses the treeview you should think about caching your data on the local system so that you
not need to read everytime the data again if the user change often the treeview. Caching is only a solution if the content is not changed so often.
0
 
chladeAuthor Commented:
Thanks.  That definitely sounds like the way to go.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now