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
Solved

Restarting while displaying data

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

860 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