PC Review


Reply
Thread Tools Rate Thread

Datatable updated by multiple threads yields datagrid problem

 
 
Becker
Guest
Posts: n/a
 
      18th Nov 2004
I have a datatable that I use to display running processes. These running
processes are spawned as different threads. I use the readerwriterlock
class to ensure that when I write to the datatable, I obtain a write lock.
The datagrid is set to have a datasource of the datatable.

The problem is that I get this error intermittently and it draws a big red X
across my datagrid:

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an
object.
at System.Data.DataColumnPropertyDescriptor.GetValue(Object component)
at
System.Windows.Forms.DataGridColumnStyle.GetColumnValueAtRow(CurrencyManager
source, Int32 rowNum)
at System.Windows.Forms.DataGridTextBoxColumn.Paint(Graphics g, Rectangle
bounds, CurrencyManager source, Int32 rowNum, Brush backBrush, Brush
foreBrush, Boolean alignToRight)
at
System.Windows.Forms.DataGridRelationshipRow.PaintCellContents(Graphics g,
Rectangle cellBounds, DataGridColumnStyle column, Brush backBr, Brush
foreBrush, Boolean alignToRight)
at System.Windows.Forms.DataGridRow.PaintData(Graphics g, Rectangle
bounds, Int32 firstVisibleColumn, Int32 columnCount, Boolean alignToRight)
at System.Windows.Forms.DataGridRelationshipRow.Paint(Graphics g,
Rectangle bounds, Rectangle trueRowBounds, Int32 firstVisibleColumn, Int32
numVisibleColumns, Boolean alignToRight)
at System.Windows.Forms.DataGrid.PaintRows(Graphics g, Rectangle&
boundingRect)
at System.Windows.Forms.DataGrid.PaintGrid(Graphics g, Rectangle
gridBounds)
at System.Windows.Forms.DataGrid.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e,
Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

Appears to be a problem with the datagrid. These threads run at the same
time updating this datatable after acquiring a lock, but what I'm not sure
is what effect this has on the datagrid since it auto-refreshes when the
datatable changes. I'm new to threading so any ideas or suggestions here
is greatly appreciated.

Thanks,
Ben



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select the row in datagrid based on the row updated in underlying datatable BijuP Microsoft VB .NET 0 18th May 2006 09:14 AM
Data Binding problem - DataTable not getting updated =?Utf-8?B?Sm9obiBDaA==?= Microsoft Dot NET Compact Framework 1 24th Jan 2005 06:06 AM
Datatable updated by multiple threads yields datagrid problem Becker Microsoft Dot NET Framework Forms 1 19th Nov 2004 03:23 AM
DataTable/DataGrid object and multiple threads Dr. Len Microsoft Dot NET 1 8th Aug 2004 08:57 PM
filling a single datatable from multiple threads Uzi Baruch Microsoft ADO .NET 2 10th Mar 2004 02:25 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:21 PM.