File tree 1 file changed +4
-20
lines changed
src/libraries/System.Drawing.Common/src/System/Drawing
1 file changed +4
-20
lines changed Original file line number Diff line number Diff line change 3
3
4
4
using System . Collections ;
5
5
using System . Diagnostics ;
6
- using System . Diagnostics . CodeAnalysis ;
7
6
using System . IO ;
8
7
using System . Reflection ;
9
- using System . Runtime . CompilerServices ;
10
- using System . Runtime . ConstrainedExecution ;
11
8
using System . Runtime . InteropServices ;
12
- using System . Threading ;
13
9
14
10
namespace System . Drawing
15
11
{
@@ -19,7 +15,9 @@ internal static partial class SafeNativeMethods
19
15
internal static partial class Gdip
20
16
{
21
17
private static readonly IntPtr s_initToken ;
22
- private const string ThreadDataSlotName = "system.drawing.threaddata" ;
18
+
19
+ [ ThreadStatic ]
20
+ private static IDictionary ? t_threadData ;
23
21
24
22
static Gdip ( )
25
23
{
@@ -47,21 +45,7 @@ static Gdip()
47
45
/// a per-thread basis. This way we can avoid 'object in use' crashes when different threads are
48
46
/// referencing the same drawing object.
49
47
/// </summary>
50
- internal static IDictionary ThreadData
51
- {
52
- get
53
- {
54
- LocalDataStoreSlot slot = Thread . GetNamedDataSlot ( ThreadDataSlotName ) ;
55
- IDictionary ? threadData = ( IDictionary ? ) Thread . GetData ( slot ) ;
56
- if ( threadData == null )
57
- {
58
- threadData = new Hashtable ( ) ;
59
- Thread . SetData ( slot , threadData ) ;
60
- }
61
-
62
- return threadData ;
63
- }
64
- }
48
+ internal static IDictionary ThreadData => t_threadData ??= new Hashtable ( ) ;
65
49
66
50
// Used to ensure static constructor has run.
67
51
internal static void DummyFunction ( )
You can’t perform that action at this time.
0 commit comments