ExecutionEngineException -> Code sample that triggers EEE

G

Guest

Hi people,

The code that follows throws an ExecutionEngineException. This was written
in C# (Microsoft Visual C# .NET 69462-335-0000007-18823) using MSDE 7.1
(7.1.3088). The framework is .NET 1.1 (1.1.4322). I tested the program on a
Windows XP Professional/SP1, with a Pentium 4/2.6Ghz processor, with 2Gb RAM.
The code is a single form that when run throws an ExecutionEngineException in
'AddRowsToTable'.

If someone with more knowledge on this matter could help me out, or point it
out to MS.NET developers I'd be grateful. If more information is needed I
will be glad to supply it. Here goes:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Test_EEE_bug
{
public class Form1 : System.Windows.Forms.Form
{
private DataTable dtSource = new DataTable( "Entries" );
private ArrayList logQueue = null;
private System.Timers.Timer logTimer = null;
private readonly object logLock = new object( );
private System.Threading.Thread workerThread = null;
private int counter = 0;

private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn1;
private System.ComponentModel.Container components = null;

private delegate void SimpleHandler( );
private delegate void AddRowsToTableHandler( DataRow[] drs );

public Form1()
{
InitializeComponent();

DataColumn dtColumn = new DataColumn( "Text", typeof(string) );
dtColumn.ReadOnly = true;
dtSource.Columns.Add( dtColumn );
dataGrid1.SetDataBinding( dtSource, null );

logQueue = new ArrayList( );

logTimer = new System.Timers.Timer( );
logTimer.AutoReset = false;
logTimer.Interval = 250;
logTimer.SynchronizingObject = null;
logTimer.Elapsed += new
System.Timers.ElapsedEventHandler(logTimer_Elapsed);
logTimer.Enabled = true;
}

private void OnLoad(object sender, System.EventArgs e)
{
SpawnThread( );
}

private void SpawnThread()
{
workerThread = new System.Threading.Thread( new
System.Threading.ThreadStart( WorkingThread ) );
workerThread.Start( );
}

private void WorkingThread( )
{
try
{
for( int i = 0; i != 8; ++i )
Write( "Log line " + ++counter );
}
finally
{
this.BeginInvoke( new SimpleHandler( SpawnThread ) );
}
}

public void Write( string text )
{
lock( logLock )
logQueue.Add( text );
}

private void logTimer_Elapsed(object sender,
System.Timers.ElapsedEventArgs e)
{
ArrayList writeOutQueue = null;
lock( logLock )
if( logQueue.Count != 0 )
{
writeOutQueue = logQueue;
logQueue = new ArrayList( );
}

if( writeOutQueue == null )
logTimer.Enabled = true;
else
{
ArrayList dataRows = new ArrayList( );

for( int i = 0; i != writeOutQueue.Count; ++i )
{
DataRow dr1 = dtSource.NewRow( );
dr1[ "Text" ] = writeOutQueue[ i ];
dataRows.Add( dr1 );
}

BeginInvoke( new AddRowsToTableHandler( AddRowsToTable ), new object[]{
(DataRow[]) dataRows.ToArray( typeof(DataRow) ) } );
}
}

private void AddRowsToTable( DataRow[] drs )
{
dataGrid1.SuspendLayout( );
dtSource.BeginLoadData( );

foreach( DataRow dr in drs )
dtSource.Rows.Add( dr );

dtSource.EndLoadData( );
dataGrid1.ResumeLayout( );

logTimer.Enabled = true;
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
this.dataGridTextBoxColumn1 = new
System.Windows.Forms.DataGridTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 8);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(592, 440);
this.dataGrid1.TabIndex = 0;
this.dataGrid1.TableStyles.AddRange(new
System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.DataGrid = this.dataGrid1;
this.dataGridTableStyle1.GridColumnStyles.AddRange(new
System.Windows.Forms.DataGridColumnStyle[] {

this.dataGridTextBoxColumn1});
this.dataGridTableStyle1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGridTableStyle1.MappingName = "";
this.dataGridTableStyle1.ReadOnly = true;
//
// dataGridTextBoxColumn1
//
this.dataGridTextBoxColumn1.Format = "";
this.dataGridTextBoxColumn1.FormatInfo = null;
this.dataGridTextBoxColumn1.HeaderText = "Text";
this.dataGridTextBoxColumn1.MappingName = "Text";
this.dataGridTextBoxColumn1.ReadOnly = true;
this.dataGridTextBoxColumn1.Width = 75;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(608, 453);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.OnLoad);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion

[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}

Kind regards,
 
B

Bob Powell [MVP]

I'll make sure someone sees this.
Thanks.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





TT (Tom Tempelaere) said:
Hi people,

The code that follows throws an ExecutionEngineException. This was written
in C# (Microsoft Visual C# .NET 69462-335-0000007-18823) using MSDE 7.1
(7.1.3088). The framework is .NET 1.1 (1.1.4322). I tested the program on
a
Windows XP Professional/SP1, with a Pentium 4/2.6Ghz processor, with 2Gb
RAM.
The code is a single form that when run throws an ExecutionEngineException
in
'AddRowsToTable'.

If someone with more knowledge on this matter could help me out, or point
it
out to MS.NET developers I'd be grateful. If more information is needed I
will be glad to supply it. Here goes:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Test_EEE_bug
{
public class Form1 : System.Windows.Forms.Form
{
private DataTable dtSource = new DataTable( "Entries" );
private ArrayList logQueue = null;
private System.Timers.Timer logTimer = null;
private readonly object logLock = new object( );
private System.Threading.Thread workerThread = null;
private int counter = 0;

private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn
dataGridTextBoxColumn1;
private System.ComponentModel.Container components = null;

private delegate void SimpleHandler( );
private delegate void AddRowsToTableHandler( DataRow[] drs );

public Form1()
{
InitializeComponent();

DataColumn dtColumn = new DataColumn( "Text", typeof(string) );
dtColumn.ReadOnly = true;
dtSource.Columns.Add( dtColumn );
dataGrid1.SetDataBinding( dtSource, null );

logQueue = new ArrayList( );

logTimer = new System.Timers.Timer( );
logTimer.AutoReset = false;
logTimer.Interval = 250;
logTimer.SynchronizingObject = null;
logTimer.Elapsed += new
System.Timers.ElapsedEventHandler(logTimer_Elapsed);
logTimer.Enabled = true;
}

private void OnLoad(object sender, System.EventArgs e)
{
SpawnThread( );
}

private void SpawnThread()
{
workerThread = new System.Threading.Thread( new
System.Threading.ThreadStart( WorkingThread ) );
workerThread.Start( );
}

private void WorkingThread( )
{
try
{
for( int i = 0; i != 8; ++i )
Write( "Log line " + ++counter );
}
finally
{
this.BeginInvoke( new SimpleHandler( SpawnThread ) );
}
}

public void Write( string text )
{
lock( logLock )
logQueue.Add( text );
}

private void logTimer_Elapsed(object sender,
System.Timers.ElapsedEventArgs e)
{
ArrayList writeOutQueue = null;
lock( logLock )
if( logQueue.Count != 0 )
{
writeOutQueue = logQueue;
logQueue = new ArrayList( );
}

if( writeOutQueue == null )
logTimer.Enabled = true;
else
{
ArrayList dataRows = new ArrayList( );

for( int i = 0; i != writeOutQueue.Count; ++i )
{
DataRow dr1 = dtSource.NewRow( );
dr1[ "Text" ] = writeOutQueue[ i ];
dataRows.Add( dr1 );
}

BeginInvoke( new AddRowsToTableHandler( AddRowsToTable ), new object[]{
(DataRow[]) dataRows.ToArray( typeof(DataRow) ) } );
}
}

private void AddRowsToTable( DataRow[] drs )
{
dataGrid1.SuspendLayout( );
dtSource.BeginLoadData( );

foreach( DataRow dr in drs )
dtSource.Rows.Add( dr );

dtSource.EndLoadData( );
dataGrid1.ResumeLayout( );

logTimer.Enabled = true;
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataGridTableStyle1 = new
System.Windows.Forms.DataGridTableStyle();
this.dataGridTextBoxColumn1 = new
System.Windows.Forms.DataGridTextBoxColumn();

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 8);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(592, 440);
this.dataGrid1.TabIndex = 0;
this.dataGrid1.TableStyles.AddRange(new
System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.DataGrid = this.dataGrid1;
this.dataGridTableStyle1.GridColumnStyles.AddRange(new
System.Windows.Forms.DataGridColumnStyle[] {

this.dataGridTextBoxColumn1});
this.dataGridTableStyle1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGridTableStyle1.MappingName = "";
this.dataGridTableStyle1.ReadOnly = true;
//
// dataGridTextBoxColumn1
//
this.dataGridTextBoxColumn1.Format = "";
this.dataGridTextBoxColumn1.FormatInfo = null;
this.dataGridTextBoxColumn1.HeaderText = "Text";
this.dataGridTextBoxColumn1.MappingName = "Text";
this.dataGridTextBoxColumn1.ReadOnly = true;
this.dataGridTextBoxColumn1.Width = 75;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(608, 453);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.OnLoad);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion

[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}

Kind regards,
 
G

Guest

Hi Bob,

After experimenting on other PC's we noticed that on one PC the exception
didn't trigger. We compared them, and noticed that one was running XP/SP2
with .NET 1.1/SP1. I'm going to upgrade the .NET framework and see if this
still occurs, but it looks like it got solved already. I'll test this further
and post my findings...

Thanks & kind regards,
--
Tom Tempelaere.


Bob Powell said:
I'll make sure someone sees this.
Thanks.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





TT (Tom Tempelaere) said:
Hi people,

The code that follows throws an ExecutionEngineException. This was written
in C# (Microsoft Visual C# .NET 69462-335-0000007-18823) using MSDE 7.1
(7.1.3088). The framework is .NET 1.1 (1.1.4322). I tested the program on
a
Windows XP Professional/SP1, with a Pentium 4/2.6Ghz processor, with 2Gb
RAM.
The code is a single form that when run throws an ExecutionEngineException
in
'AddRowsToTable'.

If someone with more knowledge on this matter could help me out, or point
it
out to MS.NET developers I'd be grateful. If more information is needed I
will be glad to supply it. Here goes:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Test_EEE_bug
{
public class Form1 : System.Windows.Forms.Form
{
private DataTable dtSource = new DataTable( "Entries" );
private ArrayList logQueue = null;
private System.Timers.Timer logTimer = null;
private readonly object logLock = new object( );
private System.Threading.Thread workerThread = null;
private int counter = 0;

private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn
dataGridTextBoxColumn1;
private System.ComponentModel.Container components = null;

private delegate void SimpleHandler( );
private delegate void AddRowsToTableHandler( DataRow[] drs );

public Form1()
{
InitializeComponent();

DataColumn dtColumn = new DataColumn( "Text", typeof(string) );
dtColumn.ReadOnly = true;
dtSource.Columns.Add( dtColumn );
dataGrid1.SetDataBinding( dtSource, null );

logQueue = new ArrayList( );

logTimer = new System.Timers.Timer( );
logTimer.AutoReset = false;
logTimer.Interval = 250;
logTimer.SynchronizingObject = null;
logTimer.Elapsed += new
System.Timers.ElapsedEventHandler(logTimer_Elapsed);
logTimer.Enabled = true;
}

private void OnLoad(object sender, System.EventArgs e)
{
SpawnThread( );
}

private void SpawnThread()
{
workerThread = new System.Threading.Thread( new
System.Threading.ThreadStart( WorkingThread ) );
workerThread.Start( );
}

private void WorkingThread( )
{
try
{
for( int i = 0; i != 8; ++i )
Write( "Log line " + ++counter );
}
finally
{
this.BeginInvoke( new SimpleHandler( SpawnThread ) );
}
}

public void Write( string text )
{
lock( logLock )
logQueue.Add( text );
}

private void logTimer_Elapsed(object sender,
System.Timers.ElapsedEventArgs e)
{
ArrayList writeOutQueue = null;
lock( logLock )
if( logQueue.Count != 0 )
{
writeOutQueue = logQueue;
logQueue = new ArrayList( );
}

if( writeOutQueue == null )
logTimer.Enabled = true;
else
{
ArrayList dataRows = new ArrayList( );

for( int i = 0; i != writeOutQueue.Count; ++i )
{
DataRow dr1 = dtSource.NewRow( );
dr1[ "Text" ] = writeOutQueue[ i ];
dataRows.Add( dr1 );
}

BeginInvoke( new AddRowsToTableHandler( AddRowsToTable ), new object[]{
(DataRow[]) dataRows.ToArray( typeof(DataRow) ) } );
}
}

private void AddRowsToTable( DataRow[] drs )
{
dataGrid1.SuspendLayout( );
dtSource.BeginLoadData( );

foreach( DataRow dr in drs )
dtSource.Rows.Add( dr );

dtSource.EndLoadData( );
dataGrid1.ResumeLayout( );

logTimer.Enabled = true;
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataGridTableStyle1 = new
System.Windows.Forms.DataGridTableStyle();
this.dataGridTextBoxColumn1 = new
System.Windows.Forms.DataGridTextBoxColumn();

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 8);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(592, 440);
this.dataGrid1.TabIndex = 0;
this.dataGrid1.TableStyles.AddRange(new
System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.DataGrid = this.dataGrid1;
this.dataGridTableStyle1.GridColumnStyles.AddRange(new
System.Windows.Forms.DataGridColumnStyle[] {

this.dataGridTextBoxColumn1});
this.dataGridTableStyle1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGridTableStyle1.MappingName = "";
this.dataGridTableStyle1.ReadOnly = true;
//
// dataGridTextBoxColumn1
//
this.dataGridTextBoxColumn1.Format = "";
this.dataGridTextBoxColumn1.FormatInfo = null;
this.dataGridTextBoxColumn1.HeaderText = "Text";
this.dataGridTextBoxColumn1.MappingName = "Text";
this.dataGridTextBoxColumn1.ReadOnly = true;
this.dataGridTextBoxColumn1.Width = 75;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(608, 453);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.OnLoad);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion

[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}

Kind regards,
 
B

Bob Powell [MVP]

While checking this to see if I could reproduce the problem using your code
I have generated log entries of many thousands of lines and no EEE so-far.
How many entries do you generate before it crashes?

If I can generate the error I'll escalate it...

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





TT (Tom Tempelaere) said:
Hi people,

The code that follows throws an ExecutionEngineException. This was written
in C# (Microsoft Visual C# .NET 69462-335-0000007-18823) using MSDE 7.1
(7.1.3088). The framework is .NET 1.1 (1.1.4322). I tested the program on
a
Windows XP Professional/SP1, with a Pentium 4/2.6Ghz processor, with 2Gb
RAM.
The code is a single form that when run throws an ExecutionEngineException
in
'AddRowsToTable'.

If someone with more knowledge on this matter could help me out, or point
it
out to MS.NET developers I'd be grateful. If more information is needed I
will be glad to supply it. Here goes:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Test_EEE_bug
{
public class Form1 : System.Windows.Forms.Form
{
private DataTable dtSource = new DataTable( "Entries" );
private ArrayList logQueue = null;
private System.Timers.Timer logTimer = null;
private readonly object logLock = new object( );
private System.Threading.Thread workerThread = null;
private int counter = 0;

private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn
dataGridTextBoxColumn1;
private System.ComponentModel.Container components = null;

private delegate void SimpleHandler( );
private delegate void AddRowsToTableHandler( DataRow[] drs );

public Form1()
{
InitializeComponent();

DataColumn dtColumn = new DataColumn( "Text", typeof(string) );
dtColumn.ReadOnly = true;
dtSource.Columns.Add( dtColumn );
dataGrid1.SetDataBinding( dtSource, null );

logQueue = new ArrayList( );

logTimer = new System.Timers.Timer( );
logTimer.AutoReset = false;
logTimer.Interval = 250;
logTimer.SynchronizingObject = null;
logTimer.Elapsed += new
System.Timers.ElapsedEventHandler(logTimer_Elapsed);
logTimer.Enabled = true;
}

private void OnLoad(object sender, System.EventArgs e)
{
SpawnThread( );
}

private void SpawnThread()
{
workerThread = new System.Threading.Thread( new
System.Threading.ThreadStart( WorkingThread ) );
workerThread.Start( );
}

private void WorkingThread( )
{
try
{
for( int i = 0; i != 8; ++i )
Write( "Log line " + ++counter );
}
finally
{
this.BeginInvoke( new SimpleHandler( SpawnThread ) );
}
}

public void Write( string text )
{
lock( logLock )
logQueue.Add( text );
}

private void logTimer_Elapsed(object sender,
System.Timers.ElapsedEventArgs e)
{
ArrayList writeOutQueue = null;
lock( logLock )
if( logQueue.Count != 0 )
{
writeOutQueue = logQueue;
logQueue = new ArrayList( );
}

if( writeOutQueue == null )
logTimer.Enabled = true;
else
{
ArrayList dataRows = new ArrayList( );

for( int i = 0; i != writeOutQueue.Count; ++i )
{
DataRow dr1 = dtSource.NewRow( );
dr1[ "Text" ] = writeOutQueue[ i ];
dataRows.Add( dr1 );
}

BeginInvoke( new AddRowsToTableHandler( AddRowsToTable ), new object[]{
(DataRow[]) dataRows.ToArray( typeof(DataRow) ) } );
}
}

private void AddRowsToTable( DataRow[] drs )
{
dataGrid1.SuspendLayout( );
dtSource.BeginLoadData( );

foreach( DataRow dr in drs )
dtSource.Rows.Add( dr );

dtSource.EndLoadData( );
dataGrid1.ResumeLayout( );

logTimer.Enabled = true;
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataGridTableStyle1 = new
System.Windows.Forms.DataGridTableStyle();
this.dataGridTextBoxColumn1 = new
System.Windows.Forms.DataGridTextBoxColumn();

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 8);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(592, 440);
this.dataGrid1.TabIndex = 0;
this.dataGrid1.TableStyles.AddRange(new
System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.DataGrid = this.dataGrid1;
this.dataGridTableStyle1.GridColumnStyles.AddRange(new
System.Windows.Forms.DataGridColumnStyle[] {

this.dataGridTextBoxColumn1});
this.dataGridTableStyle1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGridTableStyle1.MappingName = "";
this.dataGridTableStyle1.ReadOnly = true;
//
// dataGridTextBoxColumn1
//
this.dataGridTextBoxColumn1.Format = "";
this.dataGridTextBoxColumn1.FormatInfo = null;
this.dataGridTextBoxColumn1.HeaderText = "Text";
this.dataGridTextBoxColumn1.MappingName = "Text";
this.dataGridTextBoxColumn1.ReadOnly = true;
this.dataGridTextBoxColumn1.Width = 75;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(608, 453);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.OnLoad);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion

[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}

Kind regards,
 
B

Bob Powell [MVP]

Ahh, Hi, I saw this after I posted the other reply. Let me know how your
results go. If this is old news we shouldn't worry too much.

Bob.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





TT (Tom Tempelaere) said:
Hi Bob,

After experimenting on other PC's we noticed that on one PC the exception
didn't trigger. We compared them, and noticed that one was running XP/SP2
with .NET 1.1/SP1. I'm going to upgrade the .NET framework and see if this
still occurs, but it looks like it got solved already. I'll test this
further
and post my findings...

Thanks & kind regards,
--
Tom Tempelaere.


Bob Powell said:
I'll make sure someone sees this.
Thanks.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message
Hi people,

The code that follows throws an ExecutionEngineException. This was
written
in C# (Microsoft Visual C# .NET 69462-335-0000007-18823) using MSDE
7.1
(7.1.3088). The framework is .NET 1.1 (1.1.4322). I tested the program
on
a
Windows XP Professional/SP1, with a Pentium 4/2.6Ghz processor, with
2Gb
RAM.
The code is a single form that when run throws an
ExecutionEngineException
in
'AddRowsToTable'.

If someone with more knowledge on this matter could help me out, or
point
it
out to MS.NET developers I'd be grateful. If more information is needed
I
will be glad to supply it. Here goes:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Test_EEE_bug
{
public class Form1 : System.Windows.Forms.Form
{
private DataTable dtSource = new DataTable( "Entries" );
private ArrayList logQueue = null;
private System.Timers.Timer logTimer = null;
private readonly object logLock = new object( );
private System.Threading.Thread workerThread = null;
private int counter = 0;

private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn
dataGridTextBoxColumn1;
private System.ComponentModel.Container components = null;

private delegate void SimpleHandler( );
private delegate void AddRowsToTableHandler( DataRow[] drs );

public Form1()
{
InitializeComponent();

DataColumn dtColumn = new DataColumn( "Text", typeof(string) );
dtColumn.ReadOnly = true;
dtSource.Columns.Add( dtColumn );
dataGrid1.SetDataBinding( dtSource, null );

logQueue = new ArrayList( );

logTimer = new System.Timers.Timer( );
logTimer.AutoReset = false;
logTimer.Interval = 250;
logTimer.SynchronizingObject = null;
logTimer.Elapsed += new
System.Timers.ElapsedEventHandler(logTimer_Elapsed);
logTimer.Enabled = true;
}

private void OnLoad(object sender, System.EventArgs e)
{
SpawnThread( );
}

private void SpawnThread()
{
workerThread = new System.Threading.Thread( new
System.Threading.ThreadStart( WorkingThread ) );
workerThread.Start( );
}

private void WorkingThread( )
{
try
{
for( int i = 0; i != 8; ++i )
Write( "Log line " + ++counter );
}
finally
{
this.BeginInvoke( new SimpleHandler( SpawnThread ) );
}
}

public void Write( string text )
{
lock( logLock )
logQueue.Add( text );
}

private void logTimer_Elapsed(object sender,
System.Timers.ElapsedEventArgs e)
{
ArrayList writeOutQueue = null;
lock( logLock )
if( logQueue.Count != 0 )
{
writeOutQueue = logQueue;
logQueue = new ArrayList( );
}

if( writeOutQueue == null )
logTimer.Enabled = true;
else
{
ArrayList dataRows = new ArrayList( );

for( int i = 0; i != writeOutQueue.Count; ++i )
{
DataRow dr1 = dtSource.NewRow( );
dr1[ "Text" ] = writeOutQueue[ i ];
dataRows.Add( dr1 );
}

BeginInvoke( new AddRowsToTableHandler( AddRowsToTable ), new
object[]{
(DataRow[]) dataRows.ToArray( typeof(DataRow) ) } );
}
}

private void AddRowsToTable( DataRow[] drs )
{
dataGrid1.SuspendLayout( );
dtSource.BeginLoadData( );

foreach( DataRow dr in drs )
dtSource.Rows.Add( dr );

dtSource.EndLoadData( );
dataGrid1.ResumeLayout( );

logTimer.Enabled = true;
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataGridTableStyle1 = new
System.Windows.Forms.DataGridTableStyle();
this.dataGridTextBoxColumn1 = new
System.Windows.Forms.DataGridTextBoxColumn();

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 8);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(592, 440);
this.dataGrid1.TabIndex = 0;
this.dataGrid1.TableStyles.AddRange(new
System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.DataGrid = this.dataGrid1;
this.dataGridTableStyle1.GridColumnStyles.AddRange(new
System.Windows.Forms.DataGridColumnStyle[] {

this.dataGridTextBoxColumn1});
this.dataGridTableStyle1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGridTableStyle1.MappingName = "";
this.dataGridTableStyle1.ReadOnly = true;
//
// dataGridTextBoxColumn1
//
this.dataGridTextBoxColumn1.Format = "";
this.dataGridTextBoxColumn1.FormatInfo = null;
this.dataGridTextBoxColumn1.HeaderText = "Text";
this.dataGridTextBoxColumn1.MappingName = "Text";
this.dataGridTextBoxColumn1.ReadOnly = true;
this.dataGridTextBoxColumn1.Width = 75;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(608, 453);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.OnLoad);

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion

[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}

Kind regards,
 
G

Guest

Hi Bob,

Good news, I downloaded and installed .NET 1.1/SP1 and it solved the
problem. Honestly I was not aware that there was a SP1 for .NET 1.1. I find
it weird that the version number did not increase. I wonder, is SP1 for .NET
1.1 automatically installed with XP/SP2?

Kind regards,
--
Tom Tempelaere.


Bob Powell said:
Ahh, Hi, I saw this after I posted the other reply. Let me know how your
results go. If this is old news we shouldn't worry too much.

Bob.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





TT (Tom Tempelaere) said:
Hi Bob,

After experimenting on other PC's we noticed that on one PC the exception
didn't trigger. We compared them, and noticed that one was running XP/SP2
with .NET 1.1/SP1. I'm going to upgrade the .NET framework and see if this
still occurs, but it looks like it got solved already. I'll test this
further
and post my findings...

Thanks & kind regards,
--
Tom Tempelaere.


Bob Powell said:
I'll make sure someone sees this.
Thanks.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message
Hi people,

The code that follows throws an ExecutionEngineException. This was
written
in C# (Microsoft Visual C# .NET 69462-335-0000007-18823) using MSDE
7.1
(7.1.3088). The framework is .NET 1.1 (1.1.4322). I tested the program
on
a
Windows XP Professional/SP1, with a Pentium 4/2.6Ghz processor, with
2Gb
RAM.
The code is a single form that when run throws an
ExecutionEngineException
in
'AddRowsToTable'.

If someone with more knowledge on this matter could help me out, or
point
it
out to MS.NET developers I'd be grateful. If more information is needed
I
will be glad to supply it. Here goes:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Test_EEE_bug
{
public class Form1 : System.Windows.Forms.Form
{
private DataTable dtSource = new DataTable( "Entries" );
private ArrayList logQueue = null;
private System.Timers.Timer logTimer = null;
private readonly object logLock = new object( );
private System.Threading.Thread workerThread = null;
private int counter = 0;

private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn
dataGridTextBoxColumn1;
private System.ComponentModel.Container components = null;

private delegate void SimpleHandler( );
private delegate void AddRowsToTableHandler( DataRow[] drs );

public Form1()
{
InitializeComponent();

DataColumn dtColumn = new DataColumn( "Text", typeof(string) );
dtColumn.ReadOnly = true;
dtSource.Columns.Add( dtColumn );
dataGrid1.SetDataBinding( dtSource, null );

logQueue = new ArrayList( );

logTimer = new System.Timers.Timer( );
logTimer.AutoReset = false;
logTimer.Interval = 250;
logTimer.SynchronizingObject = null;
logTimer.Elapsed += new
System.Timers.ElapsedEventHandler(logTimer_Elapsed);
logTimer.Enabled = true;
}

private void OnLoad(object sender, System.EventArgs e)
{
SpawnThread( );
}

private void SpawnThread()
{
workerThread = new System.Threading.Thread( new
System.Threading.ThreadStart( WorkingThread ) );
workerThread.Start( );
}

private void WorkingThread( )
{
try
{
for( int i = 0; i != 8; ++i )
Write( "Log line " + ++counter );
}
finally
{
this.BeginInvoke( new SimpleHandler( SpawnThread ) );
}
}

public void Write( string text )
{
lock( logLock )
logQueue.Add( text );
}

private void logTimer_Elapsed(object sender,
System.Timers.ElapsedEventArgs e)
{
ArrayList writeOutQueue = null;
lock( logLock )
if( logQueue.Count != 0 )
{
writeOutQueue = logQueue;
logQueue = new ArrayList( );
}

if( writeOutQueue == null )
logTimer.Enabled = true;
else
{
ArrayList dataRows = new ArrayList( );

for( int i = 0; i != writeOutQueue.Count; ++i )
{
DataRow dr1 = dtSource.NewRow( );
dr1[ "Text" ] = writeOutQueue[ i ];
dataRows.Add( dr1 );
}

BeginInvoke( new AddRowsToTableHandler( AddRowsToTable ), new
object[]{
(DataRow[]) dataRows.ToArray( typeof(DataRow) ) } );
}
}

private void AddRowsToTable( DataRow[] drs )
{
dataGrid1.SuspendLayout( );
dtSource.BeginLoadData( );

foreach( DataRow dr in drs )
dtSource.Rows.Add( dr );

dtSource.EndLoadData( );
dataGrid1.ResumeLayout( );

logTimer.Enabled = true;
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataGridTableStyle1 = new
System.Windows.Forms.DataGridTableStyle();
this.dataGridTextBoxColumn1 = new
System.Windows.Forms.DataGridTextBoxColumn();

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 8);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(592, 440);
this.dataGrid1.TabIndex = 0;
this.dataGrid1.TableStyles.AddRange(new
System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.DataGrid = this.dataGrid1;
this.dataGridTableStyle1.GridColumnStyles.AddRange(new
System.Windows.Forms.DataGridColumnStyle[] {

this.dataGridTextBoxColumn1});
this.dataGridTableStyle1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGridTableStyle1.MappingName = "";
this.dataGridTableStyle1.ReadOnly = true;
//
// dataGridTextBoxColumn1
//
this.dataGridTextBoxColumn1.Format = "";
this.dataGridTextBoxColumn1.FormatInfo = null;
this.dataGridTextBoxColumn1.HeaderText = "Text";
this.dataGridTextBoxColumn1.MappingName = "Text";
this.dataGridTextBoxColumn1.ReadOnly = true;
this.dataGridTextBoxColumn1.Width = 75;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(608, 453);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.OnLoad);

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion

[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}

Kind regards,
 
W

Willy Denoyette [MVP]

Tom, Bob,
How did you manage to run this?
Running this program using v2.0 of the framework doesn't even get a chance
to paint the initial grid, on v1.1 the initial grid is painted but after
that the UI gets non respondive so I can't even scroll. (note both are run
on a very fast system).

The reason is simple, this:

private void SpawnThread()
{
workerThread = new System.Threading.Thread( new
System.Threading.ThreadStart( WorkingThread ) );
workerThread.Start( );
}

private void WorkingThread( )
{
try
{
for( int i = 0; i != 8; ++i )
Write( "Log line " + ++counter );
}
finally
{
BeginInvoke( new SimpleHandler( SpawnThread ) );
}
}

is respawning a thread at such a high rate that it saturates the CPU, more
,the SpawnThread function is marshaled to the UI thread, so it posts
messages at such a high rate that the essage queue overflows, input and
paint messages don't even get a chance to be picked up in a timely fashion
or are completely lost.
And... it deadlocks when run on a dual proc.

Question to Tom, is this sample illustrative for your program design?

Willy.


Bob Powell said:
While checking this to see if I could reproduce the problem using your
code I have generated log entries of many thousands of lines and no EEE
so-far. How many entries do you generate before it crashes?

If I can generate the error I'll escalate it...

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message
Hi people,

The code that follows throws an ExecutionEngineException. This was
written
in C# (Microsoft Visual C# .NET 69462-335-0000007-18823) using MSDE 7.1
(7.1.3088). The framework is .NET 1.1 (1.1.4322). I tested the program on
a
Windows XP Professional/SP1, with a Pentium 4/2.6Ghz processor, with 2Gb
RAM.
The code is a single form that when run throws an
ExecutionEngineException in
'AddRowsToTable'.

If someone with more knowledge on this matter could help me out, or point
it
out to MS.NET developers I'd be grateful. If more information is needed I
will be glad to supply it. Here goes:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Test_EEE_bug
{
public class Form1 : System.Windows.Forms.Form
{
private DataTable dtSource = new DataTable( "Entries" );
private ArrayList logQueue = null;
private System.Timers.Timer logTimer = null;
private readonly object logLock = new object( );
private System.Threading.Thread workerThread = null;
private int counter = 0;

private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn
dataGridTextBoxColumn1;
private System.ComponentModel.Container components = null;

private delegate void SimpleHandler( );
private delegate void AddRowsToTableHandler( DataRow[] drs );

public Form1()
{
InitializeComponent();

DataColumn dtColumn = new DataColumn( "Text", typeof(string) );
dtColumn.ReadOnly = true;
dtSource.Columns.Add( dtColumn );
dataGrid1.SetDataBinding( dtSource, null );

logQueue = new ArrayList( );

logTimer = new System.Timers.Timer( );
logTimer.AutoReset = false;
logTimer.Interval = 250;
logTimer.SynchronizingObject = null;
logTimer.Elapsed += new
System.Timers.ElapsedEventHandler(logTimer_Elapsed);
logTimer.Enabled = true;
}

private void OnLoad(object sender, System.EventArgs e)
{
SpawnThread( );
}

private void SpawnThread()
{
workerThread = new System.Threading.Thread( new
System.Threading.ThreadStart( WorkingThread ) );
workerThread.Start( );
}

private void WorkingThread( )
{
try
{
for( int i = 0; i != 8; ++i )
Write( "Log line " + ++counter );
}
finally
{
this.BeginInvoke( new SimpleHandler( SpawnThread ) );
}
}

public void Write( string text )
{
lock( logLock )
logQueue.Add( text );
}

private void logTimer_Elapsed(object sender,
System.Timers.ElapsedEventArgs e)
{
ArrayList writeOutQueue = null;
lock( logLock )
if( logQueue.Count != 0 )
{
writeOutQueue = logQueue;
logQueue = new ArrayList( );
}

if( writeOutQueue == null )
logTimer.Enabled = true;
else
{
ArrayList dataRows = new ArrayList( );

for( int i = 0; i != writeOutQueue.Count; ++i )
{
DataRow dr1 = dtSource.NewRow( );
dr1[ "Text" ] = writeOutQueue[ i ];
dataRows.Add( dr1 );
}

BeginInvoke( new AddRowsToTableHandler( AddRowsToTable ), new
object[]{
(DataRow[]) dataRows.ToArray( typeof(DataRow) ) } );
}
}

private void AddRowsToTable( DataRow[] drs )
{
dataGrid1.SuspendLayout( );
dtSource.BeginLoadData( );

foreach( DataRow dr in drs )
dtSource.Rows.Add( dr );

dtSource.EndLoadData( );
dataGrid1.ResumeLayout( );

logTimer.Enabled = true;
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataGridTableStyle1 = new
System.Windows.Forms.DataGridTableStyle();
this.dataGridTextBoxColumn1 = new
System.Windows.Forms.DataGridTextBoxColumn();

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 8);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(592, 440);
this.dataGrid1.TabIndex = 0;
this.dataGrid1.TableStyles.AddRange(new
System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.DataGrid = this.dataGrid1;
this.dataGridTableStyle1.GridColumnStyles.AddRange(new
System.Windows.Forms.DataGridColumnStyle[] {

this.dataGridTextBoxColumn1});
this.dataGridTableStyle1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGridTableStyle1.MappingName = "";
this.dataGridTableStyle1.ReadOnly = true;
//
// dataGridTextBoxColumn1
//
this.dataGridTextBoxColumn1.Format = "";
this.dataGridTextBoxColumn1.FormatInfo = null;
this.dataGridTextBoxColumn1.HeaderText = "Text";
this.dataGridTextBoxColumn1.MappingName = "Text";
this.dataGridTextBoxColumn1.ReadOnly = true;
this.dataGridTextBoxColumn1.Width = 75;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(608, 453);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.OnLoad);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion

[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}

Kind regards,
 
G

Guest

Hi Willy,

The UI is semi-reponsive but of course this snippet isn't representative for
the program I am writing. With semi-responsive I mean that UI interaction is
veeery slow, but I notice that the screen is still updated. After about 30000
lines, it gets even slower but still there is some response. After some more
waiting the program becomes nearly unresponsive but I notice that the UI is
still updated.

I just tried to make a program that triggered the ExecutionEngineException
and it did for .NET 1.1 without SP1. I didn't bother to write something that
made real sense.

The 'spawned' thread is actually a placeholder for the main thread in my
application. It is not supposed to finish as quick as the thread I wrote in
this test program. But in some circumstances it can terminate and then this
thread should be restarted.

What bothers me though is the deadlock situation you mention on dual
processor system. Would this be because the UI message queue is overflowing?
Does it still deadlock when you put a Sleep before invoking the SpawnThread?
There is only one 'lock'-object in the test program and I don't think that
can cause a deadlock situation... Perhaps this test-program stresses the
OS/framework to its limits?

Thanks for the input, and kind regards,
--
Tom Tempelaere.

Willy Denoyette said:
Tom, Bob,
How did you manage to run this?
Running this program using v2.0 of the framework doesn't even get a chance
to paint the initial grid, on v1.1 the initial grid is painted but after
that the UI gets non respondive so I can't even scroll. (note both are run
on a very fast system).

The reason is simple, this:

private void SpawnThread()
{
workerThread = new System.Threading.Thread( new
System.Threading.ThreadStart( WorkingThread ) );
workerThread.Start( );
}

private void WorkingThread( )
{
try
{
for( int i = 0; i != 8; ++i )
Write( "Log line " + ++counter );
}
finally
{
BeginInvoke( new SimpleHandler( SpawnThread ) );
}
}

is respawning a thread at such a high rate that it saturates the CPU, more
,the SpawnThread function is marshaled to the UI thread, so it posts
messages at such a high rate that the essage queue overflows, input and
paint messages don't even get a chance to be picked up in a timely fashion
or are completely lost.
And... it deadlocks when run on a dual proc.

Question to Tom, is this sample illustrative for your program design?

Willy.


Bob Powell said:
While checking this to see if I could reproduce the problem using your
code I have generated log entries of many thousands of lines and no EEE
so-far. How many entries do you generate before it crashes?

If I can generate the error I'll escalate it...

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message
Hi people,

The code that follows throws an ExecutionEngineException. This was
written
in C# (Microsoft Visual C# .NET 69462-335-0000007-18823) using MSDE 7.1
(7.1.3088). The framework is .NET 1.1 (1.1.4322). I tested the program on
a
Windows XP Professional/SP1, with a Pentium 4/2.6Ghz processor, with 2Gb
RAM.
The code is a single form that when run throws an
ExecutionEngineException in
'AddRowsToTable'.

If someone with more knowledge on this matter could help me out, or point
it
out to MS.NET developers I'd be grateful. If more information is needed I
will be glad to supply it. Here goes:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Test_EEE_bug
{
public class Form1 : System.Windows.Forms.Form
{
private DataTable dtSource = new DataTable( "Entries" );
private ArrayList logQueue = null;
private System.Timers.Timer logTimer = null;
private readonly object logLock = new object( );
private System.Threading.Thread workerThread = null;
private int counter = 0;

private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn
dataGridTextBoxColumn1;
private System.ComponentModel.Container components = null;

private delegate void SimpleHandler( );
private delegate void AddRowsToTableHandler( DataRow[] drs );

public Form1()
{
InitializeComponent();

DataColumn dtColumn = new DataColumn( "Text", typeof(string) );
dtColumn.ReadOnly = true;
dtSource.Columns.Add( dtColumn );
dataGrid1.SetDataBinding( dtSource, null );

logQueue = new ArrayList( );

logTimer = new System.Timers.Timer( );
logTimer.AutoReset = false;
logTimer.Interval = 250;
logTimer.SynchronizingObject = null;
logTimer.Elapsed += new
System.Timers.ElapsedEventHandler(logTimer_Elapsed);
logTimer.Enabled = true;
}

private void OnLoad(object sender, System.EventArgs e)
{
SpawnThread( );
}

private void SpawnThread()
{
workerThread = new System.Threading.Thread( new
System.Threading.ThreadStart( WorkingThread ) );
workerThread.Start( );
}

private void WorkingThread( )
{
try
{
for( int i = 0; i != 8; ++i )
Write( "Log line " + ++counter );
}
finally
{
this.BeginInvoke( new SimpleHandler( SpawnThread ) );
}
}

public void Write( string text )
{
lock( logLock )
logQueue.Add( text );
}

private void logTimer_Elapsed(object sender,
System.Timers.ElapsedEventArgs e)
{
ArrayList writeOutQueue = null;
lock( logLock )
if( logQueue.Count != 0 )
{
writeOutQueue = logQueue;
logQueue = new ArrayList( );
}

if( writeOutQueue == null )
logTimer.Enabled = true;
else
{
ArrayList dataRows = new ArrayList( );

for( int i = 0; i != writeOutQueue.Count; ++i )
{
DataRow dr1 = dtSource.NewRow( );
dr1[ "Text" ] = writeOutQueue[ i ];
dataRows.Add( dr1 );
}

BeginInvoke( new AddRowsToTableHandler( AddRowsToTable ), new
object[]{
(DataRow[]) dataRows.ToArray( typeof(DataRow) ) } );
}
}

private void AddRowsToTable( DataRow[] drs )
{
dataGrid1.SuspendLayout( );
dtSource.BeginLoadData( );

foreach( DataRow dr in drs )
dtSource.Rows.Add( dr );

dtSource.EndLoadData( );
dataGrid1.ResumeLayout( );

logTimer.Enabled = true;
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataGridTableStyle1 = new
System.Windows.Forms.DataGridTableStyle();
this.dataGridTextBoxColumn1 = new
System.Windows.Forms.DataGridTextBoxColumn();

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 8);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(592, 440);
this.dataGrid1.TabIndex = 0;
this.dataGrid1.TableStyles.AddRange(new
System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.DataGrid = this.dataGrid1;
this.dataGridTableStyle1.GridColumnStyles.AddRange(new
System.Windows.Forms.DataGridColumnStyle[] {

this.dataGridTextBoxColumn1});
this.dataGridTableStyle1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGridTableStyle1.MappingName = "";
this.dataGridTableStyle1.ReadOnly = true;
//
// dataGridTextBoxColumn1
//
this.dataGridTextBoxColumn1.Format = "";
this.dataGridTextBoxColumn1.FormatInfo = null;
this.dataGridTextBoxColumn1.HeaderText = "Text";
this.dataGridTextBoxColumn1.MappingName = "Text";
this.dataGridTextBoxColumn1.ReadOnly = true;
this.dataGridTextBoxColumn1.Width = 75;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(608, 453);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.OnLoad);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion

[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}

Kind regards,
 
W

Willy Denoyette [MVP]

TT (Tom Tempelaere) said:
Hi Willy,

The UI is semi-reponsive but of course this snippet isn't representative
for
the program I am writing. With semi-responsive I mean that UI interaction
is
veeery slow, but I notice that the screen is still updated. After about
30000
lines, it gets even slower but still there is some response. After some
more
waiting the program becomes nearly unresponsive but I notice that the UI
is
still updated.

It is 'semi responsive' when I run this on a slower system, but it's not
responsive at all when I ran this on a fast system, moreover it dealocks on
a dual proc athlon. The point is that the message queue overflows before the
first paint message on a fast system, anyway your problems is due to the
fact that the UI thread is flooded with messages to create new Threads and
because that code (your SpawnThread() function
) runs on the UI thread.


I just tried to make a program that triggered the ExecutionEngineException
and it did for .NET 1.1 without SP1. I didn't bother to write something
that
made real sense.

The 'spawned' thread is actually a placeholder for the main thread in my
application. It is not supposed to finish as quick as the thread I wrote
in
this test program. But in some circumstances it can terminate and then
this
thread should be restarted.

What bothers me though is the deadlock situation you mention on dual
processor system. Would this be because the UI message queue is
overflowing?
Does it still deadlock when you put a Sleep before invoking the
SpawnThread?

No, it doesn't deadlock with a sleep call. But I can't debug this stuff,
because when I start this from the debugger it doesn't deadlock.
There is only one 'lock'-object in the test program and I don't think that
can cause a deadlock situation... Perhaps this test-program stresses the
OS/framework to its limits?

Yes, your problem is two fold and related , you create threads at a too high
rate and you post messages (the marshaled calls to the UI thread) at such
high rate that the windows queue probably overflows (not sure though) before
the first paint message arrives. This is really something you won't do in a
real world application do you?


Willy.
 
B

Bob Powell [MVP]

It ran fine for me but I'm running a productionn machine with .NET 1.1 on
board. All my 2.0 setups are on VM's

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





Willy Denoyette said:
Tom, Bob,
How did you manage to run this?
Running this program using v2.0 of the framework doesn't even get a chance
to paint the initial grid, on v1.1 the initial grid is painted but after
that the UI gets non respondive so I can't even scroll. (note both are run
on a very fast system).

The reason is simple, this:

private void SpawnThread()
{
workerThread = new System.Threading.Thread( new
System.Threading.ThreadStart( WorkingThread ) );
workerThread.Start( );
}

private void WorkingThread( )
{
try
{
for( int i = 0; i != 8; ++i )
Write( "Log line " + ++counter );
}
finally
{
BeginInvoke( new SimpleHandler( SpawnThread ) );
}
}

is respawning a thread at such a high rate that it saturates the CPU, more
,the SpawnThread function is marshaled to the UI thread, so it posts
messages at such a high rate that the essage queue overflows, input and
paint messages don't even get a chance to be picked up in a timely fashion
or are completely lost.
And... it deadlocks when run on a dual proc.

Question to Tom, is this sample illustrative for your program design?

Willy.


Bob Powell said:
While checking this to see if I could reproduce the problem using your
code I have generated log entries of many thousands of lines and no EEE
so-far. How many entries do you generate before it crashes?

If I can generate the error I'll escalate it...

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message
Hi people,

The code that follows throws an ExecutionEngineException. This was
written
in C# (Microsoft Visual C# .NET 69462-335-0000007-18823) using MSDE
7.1
(7.1.3088). The framework is .NET 1.1 (1.1.4322). I tested the program
on a
Windows XP Professional/SP1, with a Pentium 4/2.6Ghz processor, with 2Gb
RAM.
The code is a single form that when run throws an
ExecutionEngineException in
'AddRowsToTable'.

If someone with more knowledge on this matter could help me out, or
point it
out to MS.NET developers I'd be grateful. If more information is needed
I
will be glad to supply it. Here goes:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Test_EEE_bug
{
public class Form1 : System.Windows.Forms.Form
{
private DataTable dtSource = new DataTable( "Entries" );
private ArrayList logQueue = null;
private System.Timers.Timer logTimer = null;
private readonly object logLock = new object( );
private System.Threading.Thread workerThread = null;
private int counter = 0;

private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn
dataGridTextBoxColumn1;
private System.ComponentModel.Container components = null;

private delegate void SimpleHandler( );
private delegate void AddRowsToTableHandler( DataRow[] drs );

public Form1()
{
InitializeComponent();

DataColumn dtColumn = new DataColumn( "Text", typeof(string) );
dtColumn.ReadOnly = true;
dtSource.Columns.Add( dtColumn );
dataGrid1.SetDataBinding( dtSource, null );

logQueue = new ArrayList( );

logTimer = new System.Timers.Timer( );
logTimer.AutoReset = false;
logTimer.Interval = 250;
logTimer.SynchronizingObject = null;
logTimer.Elapsed += new
System.Timers.ElapsedEventHandler(logTimer_Elapsed);
logTimer.Enabled = true;
}

private void OnLoad(object sender, System.EventArgs e)
{
SpawnThread( );
}

private void SpawnThread()
{
workerThread = new System.Threading.Thread( new
System.Threading.ThreadStart( WorkingThread ) );
workerThread.Start( );
}

private void WorkingThread( )
{
try
{
for( int i = 0; i != 8; ++i )
Write( "Log line " + ++counter );
}
finally
{
this.BeginInvoke( new SimpleHandler( SpawnThread ) );
}
}

public void Write( string text )
{
lock( logLock )
logQueue.Add( text );
}

private void logTimer_Elapsed(object sender,
System.Timers.ElapsedEventArgs e)
{
ArrayList writeOutQueue = null;
lock( logLock )
if( logQueue.Count != 0 )
{
writeOutQueue = logQueue;
logQueue = new ArrayList( );
}

if( writeOutQueue == null )
logTimer.Enabled = true;
else
{
ArrayList dataRows = new ArrayList( );

for( int i = 0; i != writeOutQueue.Count; ++i )
{
DataRow dr1 = dtSource.NewRow( );
dr1[ "Text" ] = writeOutQueue[ i ];
dataRows.Add( dr1 );
}

BeginInvoke( new AddRowsToTableHandler( AddRowsToTable ), new
object[]{
(DataRow[]) dataRows.ToArray( typeof(DataRow) ) } );
}
}

private void AddRowsToTable( DataRow[] drs )
{
dataGrid1.SuspendLayout( );
dtSource.BeginLoadData( );

foreach( DataRow dr in drs )
dtSource.Rows.Add( dr );

dtSource.EndLoadData( );
dataGrid1.ResumeLayout( );

logTimer.Enabled = true;
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataGridTableStyle1 = new
System.Windows.Forms.DataGridTableStyle();
this.dataGridTextBoxColumn1 = new
System.Windows.Forms.DataGridTextBoxColumn();

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 8);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(592, 440);
this.dataGrid1.TabIndex = 0;
this.dataGrid1.TableStyles.AddRange(new
System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.DataGrid = this.dataGrid1;
this.dataGridTableStyle1.GridColumnStyles.AddRange(new
System.Windows.Forms.DataGridColumnStyle[] {

this.dataGridTextBoxColumn1});
this.dataGridTableStyle1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGridTableStyle1.MappingName = "";
this.dataGridTableStyle1.ReadOnly = true;
//
// dataGridTextBoxColumn1
//
this.dataGridTextBoxColumn1.Format = "";
this.dataGridTextBoxColumn1.FormatInfo = null;
this.dataGridTextBoxColumn1.HeaderText = "Text";
this.dataGridTextBoxColumn1.MappingName = "Text";
this.dataGridTextBoxColumn1.ReadOnly = true;
this.dataGridTextBoxColumn1.Width = 75;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(608, 453);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.OnLoad);

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion

[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}

Kind regards,
 
W

Willy Denoyette [MVP]

Bob Powell said:
It ran fine for me but I'm running a productionn machine with .NET 1.1 on
board. All my 2.0 setups are on VM's

Do you mean you could smoothly scroll the grid? What I noticed is that the
program creates +32000 threads per second using v2.0 and +36000 on v1.1,
when run on a real fast system. This extreme high thread spawning rate
renders the UI non responsive on a fast sytem (I've seen it's handle count
going higher than 27000), on slow system the UI is more or less responsive
(well sort of). Anyway this program is a CPU hog.

Willy.
 
T

TT \(Tom Tempelaere\)

Willy, Bob,

I didn't know it could create and destroy that much threads per second. It's
worth noting :).

Thanks for the input.
Tom.
 
W

Willy Denoyette [MVP]

Note that the figures I gave in a previous post were wrong, these are the
number of messages written to the grid per second, the number of threads per
second are ~4000 and ~4500.

Actually, you don't destroy the threads, the thread procedure is just a
simple loop calling 8 times Write() followed by a call to BeginInvoke, when
this call returns the thread procedure exits and the thread terminates, now
the BeginInvoke call results in the creation of a new thread that runs the
same procedure again. That means that your thread creations are serialized
by the message loop, so you'll never have more than one such thread running.
Anyway, you are burning a lot of cycles just to write 8 messages to a grid,
the overhead of the thread creation is enormous, and again it deadlocks on a
SMP box, but I can't see why honestly.

Willy.
 
G

Guest

Hi again,

Bad news. The installation of SP1 seems to introduce other problems leading
to ExecutionEngineException's again! The problems occur less than before
(only once/twice a day for continuously running process) but is a MAJOR
obstruction to our project. I cannot express how I feel about this (at least
_very_ negative) because both .NET 1.1 and .NET 1.1/SP1 give problems with
our code.

I don't really know what to do with the problem, except cutting the
functionality from the project.

Kind regards,
--
Tom Tempelaere.


TT (Tom Tempelaere) said:
Hi Bob,

Good news, I downloaded and installed .NET 1.1/SP1 and it solved the
problem. Honestly I was not aware that there was a SP1 for .NET 1.1. I find
it weird that the version number did not increase. I wonder, is SP1 for .NET
1.1 automatically installed with XP/SP2?

Kind regards,
--
Tom Tempelaere.


Bob Powell said:
Ahh, Hi, I saw this after I posted the other reply. Let me know how your
results go. If this is old news we shouldn't worry too much.

Bob.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





TT (Tom Tempelaere) said:
Hi Bob,

After experimenting on other PC's we noticed that on one PC the exception
didn't trigger. We compared them, and noticed that one was running XP/SP2
with .NET 1.1/SP1. I'm going to upgrade the .NET framework and see if this
still occurs, but it looks like it got solved already. I'll test this
further
and post my findings...

Thanks & kind regards,
--
Tom Tempelaere.


:

I'll make sure someone sees this.
Thanks.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message
Hi people,

The code that follows throws an ExecutionEngineException. This was
written
in C# (Microsoft Visual C# .NET 69462-335-0000007-18823) using MSDE
7.1
(7.1.3088). The framework is .NET 1.1 (1.1.4322). I tested the program
on
a
Windows XP Professional/SP1, with a Pentium 4/2.6Ghz processor, with
2Gb
RAM.
The code is a single form that when run throws an
ExecutionEngineException
in
'AddRowsToTable'.

If someone with more knowledge on this matter could help me out, or
point
it
out to MS.NET developers I'd be grateful. If more information is needed
I
will be glad to supply it. Here goes:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Test_EEE_bug
{
public class Form1 : System.Windows.Forms.Form
{
private DataTable dtSource = new DataTable( "Entries" );
private ArrayList logQueue = null;
private System.Timers.Timer logTimer = null;
private readonly object logLock = new object( );
private System.Threading.Thread workerThread = null;
private int counter = 0;

private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn
dataGridTextBoxColumn1;
private System.ComponentModel.Container components = null;

private delegate void SimpleHandler( );
private delegate void AddRowsToTableHandler( DataRow[] drs );

public Form1()
{
InitializeComponent();

DataColumn dtColumn = new DataColumn( "Text", typeof(string) );
dtColumn.ReadOnly = true;
dtSource.Columns.Add( dtColumn );
dataGrid1.SetDataBinding( dtSource, null );

logQueue = new ArrayList( );

logTimer = new System.Timers.Timer( );
logTimer.AutoReset = false;
logTimer.Interval = 250;
logTimer.SynchronizingObject = null;
logTimer.Elapsed += new
System.Timers.ElapsedEventHandler(logTimer_Elapsed);
logTimer.Enabled = true;
}

private void OnLoad(object sender, System.EventArgs e)
{
SpawnThread( );
}

private void SpawnThread()
{
workerThread = new System.Threading.Thread( new
System.Threading.ThreadStart( WorkingThread ) );
workerThread.Start( );
}

private void WorkingThread( )
{
try
{
for( int i = 0; i != 8; ++i )
Write( "Log line " + ++counter );
}
finally
{
this.BeginInvoke( new SimpleHandler( SpawnThread ) );
}
}

public void Write( string text )
{
lock( logLock )
logQueue.Add( text );
}

private void logTimer_Elapsed(object sender,
System.Timers.ElapsedEventArgs e)
{
ArrayList writeOutQueue = null;
lock( logLock )
if( logQueue.Count != 0 )
{
writeOutQueue = logQueue;
logQueue = new ArrayList( );
}

if( writeOutQueue == null )
logTimer.Enabled = true;
else
{
ArrayList dataRows = new ArrayList( );

for( int i = 0; i != writeOutQueue.Count; ++i )
{
DataRow dr1 = dtSource.NewRow( );
dr1[ "Text" ] = writeOutQueue[ i ];
dataRows.Add( dr1 );
}

BeginInvoke( new AddRowsToTableHandler( AddRowsToTable ), new
object[]{
(DataRow[]) dataRows.ToArray( typeof(DataRow) ) } );
}
}

private void AddRowsToTable( DataRow[] drs )
{
dataGrid1.SuspendLayout( );
dtSource.BeginLoadData( );

foreach( DataRow dr in drs )
dtSource.Rows.Add( dr );

dtSource.EndLoadData( );
dataGrid1.ResumeLayout( );

logTimer.Enabled = true;
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataGridTableStyle1 = new
System.Windows.Forms.DataGridTableStyle();
this.dataGridTextBoxColumn1 = new
System.Windows.Forms.DataGridTextBoxColumn();

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 8);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(592, 440);
this.dataGrid1.TabIndex = 0;
this.dataGrid1.TableStyles.AddRange(new
System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.DataGrid = this.dataGrid1;
this.dataGridTableStyle1.GridColumnStyles.AddRange(new
System.Windows.Forms.DataGridColumnStyle[] {

this.dataGridTextBoxColumn1});
this.dataGridTableStyle1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGridTableStyle1.MappingName = "";
this.dataGridTableStyle1.ReadOnly = true;
//
// dataGridTextBoxColumn1
//
this.dataGridTextBoxColumn1.Format = "";
this.dataGridTextBoxColumn1.FormatInfo = null;
this.dataGridTextBoxColumn1.HeaderText = "Text";
this.dataGridTextBoxColumn1.MappingName = "Text";
this.dataGridTextBoxColumn1.ReadOnly = true;
this.dataGridTextBoxColumn1.Width = 75;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(608, 453);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.OnLoad);

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
 
G

Guest

Hi,

Once more I'm falling for the obvious trap, being, I'm posting problems I
have _way _ too fast. Misinformation led me to believe that SP1 was already
installed on the target machine, which was not the case (people who
installed, told me they had:'( ).

I apologize to this group, and to MS, for being so stupid and for not
verifying before posting. I shall try to be more clever in the future.

Kind regards,
--
Tom Tempelaere.


TT (Tom Tempelaere) said:
Hi again,

Bad news. The installation of SP1 seems to introduce other problems leading
to ExecutionEngineException's again! The problems occur less than before
(only once/twice a day for continuously running process) but is a MAJOR
obstruction to our project. I cannot express how I feel about this (at least
_very_ negative) because both .NET 1.1 and .NET 1.1/SP1 give problems with
our code.

I don't really know what to do with the problem, except cutting the
functionality from the project.

Kind regards,
--
Tom Tempelaere.


TT (Tom Tempelaere) said:
Hi Bob,

Good news, I downloaded and installed .NET 1.1/SP1 and it solved the
problem. Honestly I was not aware that there was a SP1 for .NET 1.1. I find
it weird that the version number did not increase. I wonder, is SP1 for .NET
1.1 automatically installed with XP/SP2?

Kind regards,
--
Tom Tempelaere.


Bob Powell said:
Ahh, Hi, I saw this after I posted the other reply. Let me know how your
results go. If this is old news we shouldn't worry too much.

Bob.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message Hi Bob,

After experimenting on other PC's we noticed that on one PC the exception
didn't trigger. We compared them, and noticed that one was running XP/SP2
with .NET 1.1/SP1. I'm going to upgrade the .NET framework and see if this
still occurs, but it looks like it got solved already. I'll test this
further
and post my findings...

Thanks & kind regards,
--
Tom Tempelaere.


:

I'll make sure someone sees this.
Thanks.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.





"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message
Hi people,

The code that follows throws an ExecutionEngineException. This was
written
in C# (Microsoft Visual C# .NET 69462-335-0000007-18823) using MSDE
7.1
(7.1.3088). The framework is .NET 1.1 (1.1.4322). I tested the program
on
a
Windows XP Professional/SP1, with a Pentium 4/2.6Ghz processor, with
2Gb
RAM.
The code is a single form that when run throws an
ExecutionEngineException
in
'AddRowsToTable'.

If someone with more knowledge on this matter could help me out, or
point
it
out to MS.NET developers I'd be grateful. If more information is needed
I
will be glad to supply it. Here goes:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Test_EEE_bug
{
public class Form1 : System.Windows.Forms.Form
{
private DataTable dtSource = new DataTable( "Entries" );
private ArrayList logQueue = null;
private System.Timers.Timer logTimer = null;
private readonly object logLock = new object( );
private System.Threading.Thread workerThread = null;
private int counter = 0;

private System.Windows.Forms.DataGrid dataGrid1;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn
dataGridTextBoxColumn1;
private System.ComponentModel.Container components = null;

private delegate void SimpleHandler( );
private delegate void AddRowsToTableHandler( DataRow[] drs );

public Form1()
{
InitializeComponent();

DataColumn dtColumn = new DataColumn( "Text", typeof(string) );
dtColumn.ReadOnly = true;
dtSource.Columns.Add( dtColumn );
dataGrid1.SetDataBinding( dtSource, null );

logQueue = new ArrayList( );

logTimer = new System.Timers.Timer( );
logTimer.AutoReset = false;
logTimer.Interval = 250;
logTimer.SynchronizingObject = null;
logTimer.Elapsed += new
System.Timers.ElapsedEventHandler(logTimer_Elapsed);
logTimer.Enabled = true;
}

private void OnLoad(object sender, System.EventArgs e)
{
SpawnThread( );
}

private void SpawnThread()
{
workerThread = new System.Threading.Thread( new
System.Threading.ThreadStart( WorkingThread ) );
workerThread.Start( );
}

private void WorkingThread( )
{
try
{
for( int i = 0; i != 8; ++i )
Write( "Log line " + ++counter );
}
finally
{
this.BeginInvoke( new SimpleHandler( SpawnThread ) );
}
}

public void Write( string text )
{
lock( logLock )
logQueue.Add( text );
}

private void logTimer_Elapsed(object sender,
System.Timers.ElapsedEventArgs e)
{
ArrayList writeOutQueue = null;
lock( logLock )
if( logQueue.Count != 0 )
{
writeOutQueue = logQueue;
logQueue = new ArrayList( );
}

if( writeOutQueue == null )
logTimer.Enabled = true;
else
{
ArrayList dataRows = new ArrayList( );

for( int i = 0; i != writeOutQueue.Count; ++i )
{
DataRow dr1 = dtSource.NewRow( );
dr1[ "Text" ] = writeOutQueue[ i ];
dataRows.Add( dr1 );
}

BeginInvoke( new AddRowsToTableHandler( AddRowsToTable ), new
object[]{
(DataRow[]) dataRows.ToArray( typeof(DataRow) ) } );
}
}

private void AddRowsToTable( DataRow[] drs )
{
dataGrid1.SuspendLayout( );
dtSource.BeginLoadData( );

foreach( DataRow dr in drs )
dtSource.Rows.Add( dr );

dtSource.EndLoadData( );
dataGrid1.ResumeLayout( );

logTimer.Enabled = true;
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.dataGridTableStyle1 = new
System.Windows.Forms.DataGridTableStyle();
this.dataGridTextBoxColumn1 = new
System.Windows.Forms.DataGridTextBoxColumn();

((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 8);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(592, 440);
this.dataGrid1.TabIndex = 0;
this.dataGrid1.TableStyles.AddRange(new
System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.DataGrid = this.dataGrid1;
this.dataGridTableStyle1.GridColumnStyles.AddRange(new
System.Windows.Forms.DataGridColumnStyle[] {

this.dataGridTextBoxColumn1});
this.dataGridTableStyle1.HeaderForeColor =
System.Drawing.SystemColors.ControlText;
this.dataGridTableStyle1.MappingName = "";
this.dataGridTableStyle1.ReadOnly = true;
//
// dataGridTextBoxColumn1
//
 

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