Show progress timer while databinding

D

David Smith

I have an app that shows the time it takes to execute a search, much like SQL Management Studio, but the app behaves as though the System.Windows.Forms.Timer gets blocked while binding the results to the grid. As you might expect, I execute the search in the background but I have to return to the UI thread to bind the results. While databinding, it appears as though the Timer.Tick event never gets fired, so my timer freezes at the time before the databinding, which could be the longest running part of the search.

Is my supposition that the databinding blocks the Timer correct? Is this where I should use System.Threading.Timer instead? Thanks.
 
I

Ignacio Machin ( .NET/ C# MVP )

I have an app that shows the time it takes to execute a search, much like SQL Management Studio, but the app behaves as though the System.Windows.Forms.Timer gets blocked while binding the results to the grid. As you might expect, I execute the search in the background but I have to return to the UI thread to bind the results. While databinding, it appears as though the Timer..Tick event never gets fired, so my timer freezes at the time before the databinding, which could be the longest running part of the search.

Is my supposition that the databinding blocks the Timer correct? Is this where I should use System.Threading.Timer instead? Thanks.

Hi,

I do not think you can do that, the DataBinding should be done in the
UI thread, so the UI will be frozen during it.

There is no sense to use any other timer as the UI thread is blocked
and it will not process any other mesage until it ends.

Why is your databinding taking so long though?
 
B

Ben Voigt [C++ MVP]

David said:
I have an app that shows the time it takes to execute a search, much
like SQL Management Studio, but the app behaves as though the
System.Windows.Forms.Timer gets blocked while binding the results to
the grid. As you might expect, I execute the search in the background
but I have to return to the UI thread to bind the results. While
databinding, it appears as though the Timer.Tick event never gets
fired, so my timer freezes at the time before the databinding, which
could be the longest running part of the search.

Is my supposition that the databinding blocks the Timer correct? Is
this where I should use System.Threading.Timer instead? Thanks.

You could start a new UI thread and show your progress bar there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top