Re: Report progess during black box process

Tech-Archive recommends: Fix windows errors by optimizing your registry



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.
.



Relevant Pages

  • Re: Report progess during black box process
    ... Create the DataSource in a BackGroundWorker and make sure the DataSource is ... afterwards sort it in the BackgroundWorker. ... I am reporting to the user the progress while rows are added, ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Report progess during black box process
    ... Create the DataSource in a BackGroundWorker and make sure the DataSource is ... implement your own sorting algorithm as Peter points out. ... afterwards sort it in the BackgroundWorker. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Report progess during black box process
    ... I am reporting to the user the progress while rows are added, ... reported until the sort finishes, which can take more than a minute ... If you read the documentation on BackgroundWorker (see ReportProgress ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: unittest: Calling tests in liner number order
    ... still useful to have the tests run in a certain order for reporting ... Then sort your report. ... of tests all run in a few seconds and test some basic functionality. ... but they still take a long time to fail. ...
    (comp.lang.python)
  • Re: An odd sort requirement - data munging
    ... files that range from several dozen rows deep to almost 1M rows deep. ... are actually the number you want to sort. ... Please note that the Academic year crosses year boundries, i.e., from ... 2007 to 2008, while the Reporting year crosses month boundries, i.e., ...
    (comp.lang.perl.misc)