Solved

Restarting while displaying data

Posted on 2008-06-25
2
188 Views
Last Modified: 2011-09-20
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
Comment
Question by:chlade
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
melmers earned 500 total points
ID: 21872605
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
 

Author Comment

by:chlade
ID: 21873841
Thanks.  That definitely sounds like the way to go.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question