0

I have some callback method that set on my queue some bitmap.
This callback is called every 3 millisecond.

What i mean is that my queue will be fill up with a new bitmap every 3 Millisecond.

I trying to get the first picture ( this is queue ... ) and show it on pictureBox - but i get some "external error " and i don't understand why.

public delegate void UpdateBitmapCallback( IntPtr img ); 

private void CallBack( object sender, IntPtr e )
        {
            lock( IncomingBmp )
            {
                IncomingBmp.Enqueue ( e );

                if( IncomingBmp.Count > 10)
                {
                    UpdateBitmap( IncomingBmp.Dequeue() );
                }
            }
        }

        private void UpdateBitmap( IntPtr img )
        {
            if( this.pictureBox1.InvokeRequired == true )
            {
                UpdateBitmapCallback p = new UpdateBitmapCallback( UpdateBitmap );
                this.Invoke( p, img );
            }
            else
            {
                this.pictureBox1.Image = Image.FromHbitmap( img );
            }   
        }
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by nick.crane
0

You are only storing a pointer (IntPtr) to the bitmap.
Are you sure that the bitmap still exists and is where it was when it was enqueued?
I.e. Is the pointer still valid?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.