当前位置: 首页>>代码示例>>C#>>正文


C# CanvasRenderTarget.Dispose方法代码示例

本文整理汇总了C#中CanvasRenderTarget.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# CanvasRenderTarget.Dispose方法的具体用法?C# CanvasRenderTarget.Dispose怎么用?C# CanvasRenderTarget.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CanvasRenderTarget的用法示例。


在下文中一共展示了CanvasRenderTarget.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MultithreadedSaveToFile

        public void MultithreadedSaveToFile()
        {
            //
            // This test can create a deadlock if the SaveAsync code holds on to the
            // ID2D1Multithread resource lock longer than necessary.
            //
            // A previous implementation waited until destruction of the IAsyncAction before calling Leave().  
            // In managed code this can happen on an arbitrary thread and so could result in deadlock situations
            // where other worker threads were waiting for a Leave on the original thread that never arrived.
            //

            using (new DisableDebugLayer()) // 6184116 causes the debug layer to fail when CanvasBitmap::SaveAsync is called
            {
                var task = Task.Run(async () =>
                {
                    var device = new CanvasDevice();
                    var rt = new CanvasRenderTarget(device, 16, 16, 96);

                    var filename = Path.Combine(ApplicationData.Current.TemporaryFolder.Path, "testfile.jpg");

                    await rt.SaveAsync(filename);

                    rt.Dispose();
                });

                task.Wait();
            }
        }
开发者ID:ben-sheeran,项目名称:Win2D,代码行数:28,代码来源:CanvasBitmapTests.cs

示例2: MultithreadedSaveToStream

        public void MultithreadedSaveToStream()
        {
            // This is the stream version of the above test

            var task = Task.Run(async () =>
            {
                var device = new CanvasDevice();
                var rt = new CanvasRenderTarget(device, 16, 16, 96);

                var stream = new MemoryStream();
                await rt.SaveAsync(stream.AsRandomAccessStream(), CanvasBitmapFileFormat.Bmp);

                rt.Dispose();
            });

            task.Wait();
        }
开发者ID:RainbowGardens,项目名称:Win2D,代码行数:17,代码来源:CanvasBitmapTests.cs

示例3: MultithreadedSaveToStream

        public void MultithreadedSaveToStream()
        {
            // This is the stream version of the above test

            using (new DisableDebugLayer()) // 6184116 causes the debug layer to fail when CanvasBitmap::SaveAsync is called
            {
                var task = Task.Run(async () =>
                {
                    var device = new CanvasDevice();
                    var rt = new CanvasRenderTarget(device, 16, 16, 96);

                    var stream = new MemoryStream();
                    await rt.SaveAsync(stream.AsRandomAccessStream(), CanvasBitmapFileFormat.Bmp);

                    rt.Dispose();
                });

                task.Wait();
            }
        }
开发者ID:ben-sheeran,项目名称:Win2D,代码行数:20,代码来源:CanvasBitmapTests.cs


注:本文中的CanvasRenderTarget.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。