File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,34 +76,12 @@ public Engine GetOrCreateJint(IDocument document) =>
7676 public async Task EvaluateScriptAsync ( IResponse response , ScriptOptions options , CancellationToken cancel )
7777 {
7878 var encoding = options . Encoding ?? Encoding . UTF8 ;
79- var context = options . Document . Context ;
80- var loop = context . GetService < IEventLoop > ( ) ;
8179
8280 using ( var reader = new StreamReader ( response . Content , encoding , true ) )
8381 {
8482 var content = await reader . ReadToEndAsync ( ) . ConfigureAwait ( false ) ;
85-
86- if ( loop != null )
87- {
88- var tcs = new TaskCompletionSource < Boolean > ( ) ;
89- loop . Enqueue ( _ =>
90- {
91- try
92- {
93- EvaluateScript ( options . Document , content ) ;
94- tcs . SetResult ( true ) ;
95- }
96- catch ( Exception ex )
97- {
98- tcs . SetException ( ex ) ;
99- }
100- } , TaskPriority . Critical ) ;
101- await tcs . Task . ConfigureAwait ( false ) ;
102- }
103- else
104- {
105- EvaluateScript ( options . Document , content ) ;
106- }
83+ await options . EventLoop . EnqueueAsync ( _ =>
84+ EvaluateScript ( options . Document , content ) , TaskPriority . Critical ) . ConfigureAwait ( false ) ;
10785 }
10886 }
10987
You can’t perform that action at this time.
0 commit comments