Solved

Restarting while displaying data

Posted on 2008-06-25
2
181 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
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now