Author |
Topic  |
|
GoodMorningSky
Junior Member
 
122 Posts |
Posted - 19 August 2004 : 17:10:47
|
Hi, all My app create threads transfering data and display the status on the datagrid. Most of time the number of threads are more than 100.
But, the exception comes out.. I put all try catch block. but, it is not catched since the exception occurs while painting datagrid i guess. Exception:
Exception: from output window MsgEach:170, PayrollReport: 327/725 ********** Dead Thread: MsgEach:165, PayrollReport: 511/780 MsgEach:166, PayrollReport: 512/672 MsgEach:165, PayrollReport: 512/780 MsgEach:166, PayrollReport: 513/672 MsgEach:170, PayrollReport: 328/725 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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at TimeClockAdmin.frmMDIMain.Main() in c:\projects\new time clock release\new time clock hq\timeclockadmin\frmmdimain.cs:line 497 MsgEach:165, PayrollReport: 513/780 Object reference not set to an instance of an object. MsgEach:166, PayrollReport: 514/672 MsgEach:170, PayrollReport: 329/725
this exception occurs from:
[STAThread] static void Main() { try { if (SkyComponents.SkyWinUtils.PrevInstance()) { MessageBox.Show ("Program is already running!"); return; } Application.Run(new frmMDIMain()); } catch(Exception ex) { Debug.WriteLine("********** Dead Thread: " + Thread.CurrentThread.Name); Debug.WriteLine(ex.StackTrace); Debug.WriteLine(ex.Message); //here.. } } [/CODE]
Writing message method called by each thread..
private void MsgEach(int idx, string msg) { Debug.WriteLine("MsgEach:" + idx + ", " + msg); try { deptList.Rows[idx]["Message"] = msg; } catch { Debug.WriteLine("MsgEach"); } }
[/CODE]
This problem comes out since DataGrid painting is not thread safe.. Then what should I do????? After the exception occurs the Application GUI disappears, but the task threads still work.. I think the GUI painting thread (in java AWTThread..) throw exception and die..
This problem doesn't occurs every time.. at the same moment..
Any idea to solve this problem????[/QUOTE]
|
Software Engineer. MCSD.NET, SCWCD |
|
GoodMorningSky
Junior Member
 
122 Posts |
Posted - 19 August 2004 : 17:13:43
|
This is very common problem. Control is being painted by one thread!(in java it's called AWTThread).
If muti thread is running and show their result to a control, then the control throws exception while repainting...
The above question is about one of the problem.
How to synchronize it? Is any pattern doing this? |
Software Engineer. MCSD.NET, SCWCD |
 |
|
pdrg
Support Moderator
    
United Kingdom
2897 Posts |
Posted - 20 August 2004 : 06:45:12
|
Hi, not that I don't want to help, but you may get more mileage asking a C# forum somewhere (howabout asking on one of the excellent C# groups on usenet?)
I think you're more likely to get what you need.
hth |
 |
|
|
Topic  |
|
|
|