本文整理汇总了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();
}
}
示例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();
}
示例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();
}
}