Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datagridview retains waitcursor when updated from thread

I have a DataGridView control in my Windows Forms Application. I am adding rows to the grid using a background thread. I change the form's cursor to Waitcursor when the process starts and back to Default when it ends. This works well for the form, but not for the grid. When the form's cursor is changed back to default, the grid's cursor does not change, although the cursor over the rest of the form does.

Does this have anything to do with the fact that I am updating the grid from a background thread? (The cursor is being changed from the UI thread directly).

Edit: The background process raises an event, the handler checks the InvokeRequired property of the grid and decides if it needs to "Invoke" the method again from the main thread. So, in effect the actual UI update happens from the appropriate thread. I am not sure if this means that I am "using a background thread" or not. :|

like image 713
Apeksha Avatar asked Dec 17 '22 00:12

Apeksha


1 Answers

I've had some problems doing single thread updating of my datagrids, where the datagrid did not reset to normal cursor after i've had waitcursor to true. What I did was right after i went

this.UseWaitCursor = false;

I added

DatagridviewFoo.Cursor = this.Cursor;

Maybe it's just the same problem for you

like image 164
imonsei Avatar answered Dec 31 '22 14:12

imonsei