Exemplo n.º 1
0
        private void OnTick(object sender, EventArgs e)
        {
            if (RenderResult == null)
            {
                return;
            }

            bool isUpdated;

            lock (RenderResult)
            {
                isUpdated = RenderResult.IsUpdated;
            }

            if (isUpdated)
            {
                Bitmap bitmap = RenderResult.CreateBitmap();

                using (Stream stream = new MemoryStream())
                {
                    bitmap.Save(stream, ImageFormat.Png);
                    stream.Seek(0, SeekOrigin.Begin);

                    image.Source = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
                }

                lock (RenderResult)
                {
                    RenderResult.IsUpdated = false;
                }
            }
        }