Re: Report progess during black box process
- From: Bill <billsahiker@xxxxxxxxx>
- Date: Fri, 8 May 2009 13:19:01 -0700 (PDT)
On May 8, 3:56 am, Morten Wennevik [C# MVP]
<MortenWenne...@xxxxxxxxxxx> wrote:
Hi Bill,
Create the DataSource in a BackGroundWorker and make sure the DataSource is
sorted before adding it to the DataGridView. Use the
BackgroundWorker.ProgressChanged event (which is thread safe) or Invoke your
own methods when you need to display changes. Remember that lots of
events/invokes are expensive and may drastically slow the whole process down.
Keep a counter and only update if((counter % 1000) == 0) or similar. You
won't be able to report progress during the actual sorting unless you
implement your own sorting algorithm as Peter points out.
If you get the rows from a query, the fastest way would be to get the rows
presorted by doing the sorting as part of the query. If you need to sort it
afterwards sort it in the BackgroundWorker. If you need to use
DataGridView.Sort, implement paging and lower the number of rows displayed.
--
Happy Coding!
Morten Wennevik [C# MVP]
"Bill" wrote:
I am using a dataview to sort a table that can have a million or so
rows. I am reporting to the user the progress while rows are added,
but when the code executes the Sort method there is no progress
reported until the sort finishes, which can take more than a minute
and the Task Manager indicates the application is not responding. I
dont want users to think it has hung. I was thinking about using a
timer to periodically display something, but the process is being
executed in a backgroundworker. Any suggestions?
Bill- Hide quoted text -
- Show quoted text -
I should have been clearer about the problem. I do not have a
datasource. the code adds rows to a datatable and I am using the
dataview to sort it. The problem is that once the dataview sort method
is invoked, it is essentiall a "black box" as I have no way of
knowing how long it will take or any way of reporting percentage
progress. I already am using the backgroundworker reportprogress
method and I change the counter to a "Sorting..." message, but the
sort takes a while and the task manager sometimes indicates the
application is not responding. One of the replies suggested faking it
and periodically displaying some kind of update message using the
reportprogress, and that appears to be the best strategy.
.
- Follow-Ups:
- Re: Report progess during black box process
- From: Morten Wennevik [C# MVP]
- Re: Report progess during black box process
- From: Pavel Minaev
- Re: Report progess during black box process
- References:
- Report progess during black box process
- From: Bill
- RE: Report progess during black box process
- From: Morten Wennevik [C# MVP]
- Report progess during black box process
- Prev by Date: Null or Not Null
- Next by Date: RE: multi-thread update to RichTextBox
- Previous by thread: RE: Report progess during black box process
- Next by thread: Re: Report progess during black box process
- Index(es):
Relevant Pages
|