11using Microsoft . IO ;
2+ using System . Collections . Concurrent ;
23using System . Diagnostics ;
34using System . Drawing ;
45using System . Runtime . InteropServices ;
@@ -115,7 +116,7 @@ uint uFlags
115116 return null ;
116117 }
117118
118- const int maxCache = 500 ;
119+ // const int maxCache = 500;
119120
120121 static void SetCache ( string ext , Bitmap ? icon )
121122 {
@@ -124,16 +125,16 @@ static void SetCache(string ext,Bitmap? icon)
124125
125126 if ( ! iconCache . ContainsKey ( ext ) )
126127 {
127- if ( iconCache . Count ( ) > maxCache )
128- {
129- foreach ( var item in iconCache )
130- {
131- item . Value . Dispose ( ) ;
132- }
133- iconCache . Clear ( ) ;
134- }
128+ // if (iconCache.Count() > maxCache)
129+ // {
130+ // foreach (var item in iconCache)
131+ // {
132+ // item.Value.Dispose();
133+ // }
134+ // iconCache.Clear();
135+ // }
135136
136- iconCache . Add ( ext , icon ) ;
137+ iconCache . TryAdd ( ext , icon ) ;
137138 }
138139 }
139140
@@ -142,12 +143,12 @@ static bool GetCache(string ext, out Bitmap? icon)
142143 return iconCache . TryGetValue ( ext , out icon ) ;
143144 }
144145
145- static Dictionary < string , Bitmap > iconCache = new Dictionary < string , Bitmap > ( 64 ) ;
146+ static ConcurrentDictionary < string , Bitmap > iconCache = new ConcurrentDictionary < string , Bitmap > ( ) ;
146147
147148
148149 private static readonly RecyclableMemoryStreamManager
149150 recyclableMemoryStreamManager =
150- new RecyclableMemoryStreamManager ( new RecyclableMemoryStreamManager . Options ( 2048 , 2048 , 4096 , 2048 * 500 , 2048 * 500 ) ) ;
151+ new RecyclableMemoryStreamManager ( /* new RecyclableMemoryStreamManager.Options(2048, 2048,4096, 2048 * 500, 2048 * 500)*/ ) ;
151152 private static Bitmap ? ConvertToAvaloniaBitmap ( System . Drawing . Bitmap systemBitmap )
152153 {
153154 int targetSize = 32 ;
0 commit comments