예제 #1
0
        /// <summary>
        /// Takes a screenshot and returns it as a gdi bitmap.
        /// </summary>
        public static Task <GDI.Bitmap> GetScreenshotGdiAsync(this RenderLoop renderLoop)
        {
            var result = new TaskCompletionSource <GDI.Bitmap>(TaskCreationOptions.RunContinuationsAsynchronously);

            renderLoop.EnqueueAfterPresentAction(() =>
            {
                try
                {
                    var resultBitmap = GetScreenshotGdiInternal(renderLoop);
                    result.SetResult(resultBitmap);
                }
                catch (Exception ex)
                {
                    result.SetException(ex);
                }
            });

            return(result.Task);
        }