@@ -19,8 +19,8 @@ namespace CefSharp.Internals
19
19
/// <typeparam name="TResult">The type of the result produced by the tasks held.</typeparam>
20
20
public sealed class PendingTaskRepository < TResult >
21
21
{
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 > > ( ) ;
24
24
//should only be accessed by Interlocked.Increment
25
25
private long lastId ;
26
26
@@ -39,7 +39,7 @@ public KeyValuePair<long, TaskCompletionSource<TResult>> CreatePendingTask(strin
39
39
#if NETCOREAPP
40
40
framePendingTasks . AddOrUpdate (
41
41
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 ; } ,
43
43
( key , value , state ) => { value . PendingTasks . TryAdd ( state . Key , state . Value ) ; return value ; } ,
44
44
result
45
45
) ;
@@ -74,7 +74,7 @@ public KeyValuePair<long, TaskCompletionSource<TResult>> CreateJavascriptCallbac
74
74
#if NETCOREAPP
75
75
framePendingTasks . AddOrUpdate (
76
76
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 ; } ,
78
78
( key , value , state ) => { value . CallbackPendingTasks . TryAdd ( state . Key , state . Value ) ; return value ; } ,
79
79
result
80
80
) ;
@@ -106,7 +106,7 @@ public KeyValuePair<long, TaskCompletionSource<TResult>> CreateJavascriptCallbac
106
106
/// </returns>
107
107
public TaskCompletionSource < TResult > RemovePendingTask ( string frameId , long id )
108
108
{
109
- FramePendingTaskRepository repository ;
109
+ FramePendingTaskRepository < TResult > repository ;
110
110
if ( framePendingTasks . TryGetValue ( frameId , out repository ) )
111
111
{
112
112
TaskCompletionSource < TResult > result ;
@@ -131,7 +131,7 @@ public TaskCompletionSource<TResult> RemovePendingTask(string frameId, long id)
131
131
/// </returns>
132
132
public TaskCompletionSource < TResult > RemoveJavascriptCallbackPendingTask ( string frameId , long id )
133
133
{
134
- FramePendingTaskRepository repository ;
134
+ FramePendingTaskRepository < TResult > repository ;
135
135
if ( framePendingTasks . TryGetValue ( frameId , out repository ) )
136
136
{
137
137
TaskCompletionSource < TResult > result ;
@@ -150,7 +150,7 @@ public TaskCompletionSource<TResult> RemoveJavascriptCallbackPendingTask(string
150
150
/// <param name="frameId">The frame id.</param>
151
151
public void CancelPendingTasks ( string frameId )
152
152
{
153
- FramePendingTaskRepository repository ;
153
+ FramePendingTaskRepository < TResult > repository ;
154
154
if ( framePendingTasks . TryRemove ( frameId , out repository ) )
155
155
{
156
156
repository . Dispose ( ) ;
@@ -168,28 +168,5 @@ public void CancelPendingTasks()
168
168
}
169
169
framePendingTasks . Clear ( ) ;
170
170
}
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
- }
194
171
}
195
172
}
0 commit comments