/
BufferedGraphicsManager.cs
33 lines (29 loc) · 1.15 KB
/
BufferedGraphicsManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Runtime.ConstrainedExecution;
namespace System.Drawing
{
/// <summary>
/// The BufferedGraphicsManager is used for accessing a BufferedGraphicsContext.
/// </summary>
public static class BufferedGraphicsManager
{
/// <summary>
/// Static constructor. Here, we hook the exit & unload events so we can clean up our context buffer.
/// </summary>
static BufferedGraphicsManager()
{
AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnShutdown);
AppDomain.CurrentDomain.DomainUnload += new EventHandler(OnShutdown);
Current = new BufferedGraphicsContext();
}
/// <summary>
/// Retrieves the context associated with the app domain.
/// </summary>
public static BufferedGraphicsContext Current { get; }
/// <summary>
/// Called on process exit
/// </summary>
private static void OnShutdown(object? sender, EventArgs e) => Current.Invalidate();
}
}