public void DownloadFile(string url, string path, Action?onSuccess, Action <Exception>?onError) { cefAdapter.RunOnUiThread(() => { var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read); try { var request = browser.CreateGetRequest(); requestAdapter.SetUrl(request, url); requestAdapter.SetMethod(request, "GET"); requestAdapter.SetReferrer(request, Url); requestAdapter.SetAllowStoredCredentials(request); using TFrame frame = browser.MainFrame; browser.RequestDownload(frame, request, new DownloadCallbacks(fileStream, onSuccess, onError)); } catch (Exception e) { fileStream.Dispose(); onError?.Invoke(e); } }); }