@@ -19,8 +19,8 @@ namespace CefSharp.Internals
1919 /// <typeparam name="TResult">The type of the result produced by the tasks held.</typeparam>
2020 public sealed class PendingTaskRepository < TResult >
2121 {
22- private readonly ConcurrentDictionary < string , FramePendingTaskRepository > framePendingTasks =
23- new ConcurrentDictionary < string , FramePendingTaskRepository > ( ) ;
22+ private readonly ConcurrentDictionary < string , FramePendingTaskRepository < TResult > > framePendingTasks =
23+ new ConcurrentDictionary < string , FramePendingTaskRepository < TResult > > ( ) ;
2424 //should only be accessed by Interlocked.Increment
2525 private long lastId ;
2626
@@ -39,7 +39,7 @@ public KeyValuePair<long, TaskCompletionSource<TResult>> CreatePendingTask(strin
3939#if NETCOREAPP
4040 framePendingTasks . AddOrUpdate (
4141 frameId ,
42- ( key , state ) => { var value = new FramePendingTaskRepository ( ) ; value . PendingTasks . TryAdd ( state . Key , state . Value ) ; return value ; } ,
42+ ( key , state ) => { var value = new FramePendingTaskRepository < TResult > ( ) ; value . PendingTasks . TryAdd ( state . Key , state . Value ) ; return value ; } ,
4343 ( key , value , state ) => { value . PendingTasks . TryAdd ( state . Key , state . Value ) ; return value ; } ,
4444 result
4545 ) ;
@@ -74,7 +74,7 @@ public KeyValuePair<long, TaskCompletionSource<TResult>> CreateJavascriptCallbac
7474#if NETCOREAPP
7575 framePendingTasks . AddOrUpdate (
7676 frameId ,
77- ( key , state ) => { var value = new FramePendingTaskRepository ( ) ; value . CallbackPendingTasks . TryAdd ( state . Key , state . Value ) ; return value ; } ,
77+ ( key , state ) => { var value = new FramePendingTaskRepository < TResult > ( ) ; value . CallbackPendingTasks . TryAdd ( state . Key , state . Value ) ; return value ; } ,
7878 ( key , value , state ) => { value . CallbackPendingTasks . TryAdd ( state . Key , state . Value ) ; return value ; } ,
7979 result
8080 ) ;
@@ -106,7 +106,7 @@ public KeyValuePair<long, TaskCompletionSource<TResult>> CreateJavascriptCallbac
106106 /// </returns>
107107 public TaskCompletionSource < TResult > RemovePendingTask ( string frameId , long id )
108108 {
109- FramePendingTaskRepository repository ;
109+ FramePendingTaskRepository < TResult > repository ;
110110 if ( framePendingTasks . TryGetValue ( frameId , out repository ) )
111111 {
112112 TaskCompletionSource < TResult > result ;
@@ -131,7 +131,7 @@ public TaskCompletionSource<TResult> RemovePendingTask(string frameId, long id)
131131 /// </returns>
132132 public TaskCompletionSource < TResult > RemoveJavascriptCallbackPendingTask ( string frameId , long id )
133133 {
134- FramePendingTaskRepository repository ;
134+ FramePendingTaskRepository < TResult > repository ;
135135 if ( framePendingTasks . TryGetValue ( frameId , out repository ) )
136136 {
137137 TaskCompletionSource < TResult > result ;
@@ -150,7 +150,7 @@ public TaskCompletionSource<TResult> RemoveJavascriptCallbackPendingTask(string
150150 /// <param name="frameId">The frame id.</param>
151151 public void CancelPendingTasks ( string frameId )
152152 {
153- FramePendingTaskRepository repository ;
153+ FramePendingTaskRepository < TResult > repository ;
154154 if ( framePendingTasks . TryRemove ( frameId , out repository ) )
155155 {
156156 repository . Dispose ( ) ;
@@ -168,28 +168,5 @@ public void CancelPendingTasks()
168168 }
169169 framePendingTasks . Clear ( ) ;
170170 }
171-
172- private sealed class FramePendingTaskRepository : IDisposable
173- {
174- public ConcurrentDictionary < long , TaskCompletionSource < TResult > > PendingTasks { get ; } =
175- new ConcurrentDictionary < long , TaskCompletionSource < TResult > > ( ) ;
176- public ConcurrentDictionary < long , TaskCompletionSource < TResult > > CallbackPendingTasks { get ; } =
177- new ConcurrentDictionary < long , TaskCompletionSource < TResult > > ( ) ;
178-
179- public void Dispose ( )
180- {
181- foreach ( var tcs in PendingTasks . Values )
182- {
183- tcs . TrySetCanceled ( ) ;
184- }
185- PendingTasks . Clear ( ) ;
186-
187- foreach ( var tcs in CallbackPendingTasks . Values )
188- {
189- tcs . TrySetCanceled ( ) ;
190- }
191- CallbackPendingTasks . Clear ( ) ;
192- }
193- }
194171 }
195172}
0 commit comments