Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions Source/SpiderEye.Mac/CocoaWebview.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
Expand Down Expand Up @@ -105,10 +105,9 @@ public void LoadUri(Uri uri)
ObjC.Call(Handle, "loadRequest:", request);
}

public Task<string?> ExecuteScriptAsync(string script)
public async Task<string?> ExecuteScriptAsync(string script)
{
var taskResult = new TaskCompletionSource<string?>();
NSBlock? block = null;

ScriptEvalCallbackDelegate callback = (IntPtr self, IntPtr result, IntPtr error) =>
{
Expand All @@ -126,17 +125,16 @@ public void LoadUri(Uri uri)
}
}
catch (Exception ex) { taskResult.TrySetException(ex); }
finally { block!.Dispose(); }
};

block = new NSBlock(callback);
using NSBlock block = new NSBlock(callback);
ObjC.Call(
Handle,
"evaluateJavaScript:completionHandler:",
NSString.Create(script),
block.Handle);

return taskResult.Task;
return await taskResult.Task;
}

public void Dispose()
Expand Down