Restarting while displaying data
Posted on 2008-06-25
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?