File tree Expand file tree Collapse file tree 1 file changed +4
-20
lines changed
src/libraries/System.Drawing.Common/src/System/Drawing Expand file tree Collapse file tree 1 file changed +4
-20
lines changed Original file line number Diff line number Diff line change 33
44using System . Collections ;
55using System . Diagnostics ;
6- using System . Diagnostics . CodeAnalysis ;
76using System . IO ;
87using System . Reflection ;
9- using System . Runtime . CompilerServices ;
10- using System . Runtime . ConstrainedExecution ;
118using System . Runtime . InteropServices ;
12- using System . Threading ;
139
1410namespace System . Drawing
1511{
@@ -19,7 +15,9 @@ internal static partial class SafeNativeMethods
1915 internal static partial class Gdip
2016 {
2117 private static readonly IntPtr s_initToken ;
22- private const string ThreadDataSlotName = "system.drawing.threaddata" ;
18+
19+ [ ThreadStatic ]
20+ private static IDictionary ? t_threadData ;
2321
2422 static Gdip ( )
2523 {
@@ -47,21 +45,7 @@ static Gdip()
4745 /// a per-thread basis. This way we can avoid 'object in use' crashes when different threads are
4846 /// referencing the same drawing object.
4947 /// </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 ( ) ;
6549
6650 // Used to ensure static constructor has run.
6751 internal static void DummyFunction ( )
You can’t perform that action at this time.
0 commit comments