Solved

Restarting while displaying data

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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