470,613 Members | 2,353 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,613 developers. It's quick & easy.

Sort datagrid (ThreadSystem.NullReferenceException in system.windows.forms.dll)

Please help

I have the problem that when I change the data in a
Windows.Forms.DataGrid by a separate thread the following
Exception is thrown:

ThreadSystem.NullReferenceException in
system.windows.forms.dll

I can't catch this Exception and it only occurs when I
allow sorting in the grid and choose the changing column
to sort.

I tried several things like monitors, suspend layout etc.
but nothing helped.
In the Threads Window of Visual Studio I can see that
there is an extra thread with the highest priority. I
assume that this one do the sorting in the background and
causes this exception.

Is this a bug of the datagrid or not and has anybody a
suggestion to solve this problem?

I have written a small test application to reproduce this
behavior. If you are interested I can send it to you.

Thanks
Ben

Nov 20 '05 #1
3 2235
Hi Ben,

No takers with just the message. I reckon you're gonna have to send that
Project.

Regards,
Fergus
Nov 20 '05 #2
On 2003-10-30, mahtan <Be***********@hotmail.com> wrote:
Please help

I have the problem that when I change the data in a
Windows.Forms.DataGrid by a separate thread the following
Exception is thrown:

ThreadSystem.NullReferenceException in
system.windows.forms.dll

I can't catch this Exception and it only occurs when I
allow sorting in the grid and choose the changing column
to sort.

I tried several things like monitors, suspend layout etc.
but nothing helped.
In the Threads Window of Visual Studio I can see that
there is an extra thread with the highest priority. I
assume that this one do the sorting in the background and
causes this exception.

Is this a bug of the datagrid or not and has anybody a
suggestion to solve this problem?

I have written a small test application to reproduce this
behavior. If you are interested I can send it to you.

Thanks
Ben


Please do. But, I have to ask - are you trying to update the DataGrid
directly from the background thread? Because if you are, that is most
likely the source of your error. Windows forms controls are not thread
safe. All, except for 4, methods and properties must be called from the
GUI thread.

--
Tom Shelton
MVP [Visual Basic]
Nov 20 '05 #3
* Tom Shelton <to*@mtogden.com> scripsit:
Please do. But, I have to ask - are you trying to update the DataGrid
directly from the background thread? Because if you are, that is most
likely the source of your error. Windows forms controls are not thread
safe. All, except for 4, methods and properties must be called from the
GUI thread.


A good introduction to Windows Forms + Multithreading can be found here:

<http://www.devx.com/dotnet/Article/11358>

--
Herfried K. Wagner
MVP ∑ VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Steve | last post: by
2 posts views Thread by Flack | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.