How to Debug FatalExecutionEngineError ( WinForm / Bitmap / Timer)

  • Thread starter Thread starter DongYeop,Choi
  • Start date Start date
D

DongYeop,Choi

Guest
Hello!

Somebody Help me please!!!!

I have some timer that elapsed 200 ms.

If timer elapsed, make 2 byte array ( size is 3840 * 1250 ) and generate event. (below)

private void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
System.Threading.Thread tr = new System.Threading.Thread(() =>
{
int trID = System.Threading.Thread.CurrentThread.ManagedThreadId;

byte[] source1 = BitmapUtilities.GenerateSourceData(this._sourceDataLength);
byte[] srouce2 = BitmapUtilities.GenerateSourceData(this._sourceDataLength);

if (UpdateSourceData != null)
UpdateSourceData(this, new ImageGenerateEventArgs(Count, this._width, this._height, source1, srouce2));
});
tr.IsBackground = true;
tr.Start();
}

and then, event receivers are Create Bitmap and Update Image to PictureBoxs...

private void ImageViewer_UpdateSourceData(object sender, ImageGenerateEventArgs args)
{
Action lambda = () =>
{
int trID = System.Threading.Thread.CurrentThread.ManagedThreadId;
Bitmap bitmap = BitmapUtilities.CreateBitmapFromByteSource(args.W, args.H, args.S1);
bitmap.RotateFlip(RotateFlipType.Rotate180FlipX);

if (this.pictureBox1.Image != null)
this.pictureBox1.Image.Dispose();

this.pictureBox1.Image = bitmap;
this.pictureBox1.Update();
bitmap.Dispose();

bitmap = BitmapUtilities.CreateBitmapFromByteSource(args.W, args.H, args.S2);
bitmap.RotateFlip(RotateFlipType.Rotate180FlipX);

if (this.pictureBox2.Image != null)
this.pictureBox2.Image.Dispose();

this.pictureBox2.Image = bitmap;
this.pictureBox2.Update();

bitmap.Dispose();
};

if (this.InvokeRequired)
this.Invoke(lambda);
else
lambda();
}



But, I have a problem Fatal Execution Engine Exception...in

'BitmapUtilities.CreateBitmapFromByteSource(args.W, args.H, args.S1);'

static public Bitmap CreateBitmapFromByteSource(int width, int height, byte[] byteSource)
{
Bitmap image;
BitmapSource src;
try
{
src = BitmapSource.Create(width, height, 96, 96, System.Windows.Media.PixelFormats.Gray8, null, byteSource, width);
using (MemoryStream ms = new MemoryStream())
{
BitmapEncoder enc = new BmpBitmapEncoder();
enc.Frames.Add(BitmapFrame.Create(src));
enc.Save(ms);
image = new System.Drawing.Bitmap(ms);
}

return image;
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
return null;
}
}


Please Help me....

Continue reading...
 
Back
Top