未验证 提交 1def8a79 编写于 作者: A Alex Maitland 提交者: GitHub

Upgrade to .Net 4.6.2 (#4482)

* Upgrade minimum .Net version to 4.6.2

#4433

* Use TaskCreationOptions.RunContinuationsAsynchronously

- Now that min version is .Net 4.6.2 we can use RunContinuationsAsynchronously
- Remove some unused code
上级 25210527
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\cef.sdk.114.2.10\build\cef.sdk.props" Condition="Exists('..\packages\cef.sdk.114.2.10\build\cef.sdk.props')" /> <Import Project="..\packages\cef.sdk.114.2.10\build\cef.sdk.props" Condition="Exists('..\packages\cef.sdk.114.2.10\build\cef.sdk.props')" />
<Import Project="..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props" Condition="Exists('..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props')" /> <Import Project="..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props" Condition="Exists('..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props')" />
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<ProjectGuid>{6C4BB501-2F8E-48AC-9AB5-8CFB2D74185C}</ProjectGuid> <ProjectGuid>{6C4BB501-2F8E-48AC-9AB5-8CFB2D74185C}</ProjectGuid>
<Keyword>ManagedCProj</Keyword> <Keyword>ManagedCProj</Keyword>
<RootNamespace>CefSharpBrowserSubprocessCore</RootNamespace> <RootNamespace>CefSharpBrowserSubprocessCore</RootNamespace>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
...@@ -261,4 +261,4 @@ ...@@ -261,4 +261,4 @@
<Import Project="..\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets" Condition="Exists('..\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets')" /> <Import Project="..\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets" Condition="Exists('..\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets')" />
<Import Project="..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets" Condition="Exists('..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets')" /> <Import Project="..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets" Condition="Exists('..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets')" />
</ImportGroup> </ImportGroup>
</Project> </Project>
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net452</TargetFramework> <TargetFramework>net462</TargetFramework>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<Platforms>x86;x64</Platforms> <Platforms>x86;x64</Platforms>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
......
<?xml version="1.0"?> <?xml version="1.0"?>
<configuration> <configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup></configuration> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/></startup></configuration>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\cef.sdk.114.2.10\build\cef.sdk.props" Condition="Exists('..\packages\cef.sdk.114.2.10\build\cef.sdk.props')" /> <Import Project="..\packages\cef.sdk.114.2.10\build\cef.sdk.props" Condition="Exists('..\packages\cef.sdk.114.2.10\build\cef.sdk.props')" />
<Import Project="..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props" Condition="Exists('..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props')" /> <Import Project="..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props" Condition="Exists('..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.props')" />
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<ProjectGuid>{7B495581-2271-4F41-9476-ACB86E8C864F}</ProjectGuid> <ProjectGuid>{7B495581-2271-4F41-9476-ACB86E8C864F}</ProjectGuid>
<RootNamespace>CefSharp</RootNamespace> <RootNamespace>CefSharp</RootNamespace>
<Keyword>ManagedCProj</Keyword> <Keyword>ManagedCProj</Keyword>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="..\CefSharp.props" /> <Import Project="..\CefSharp.props" />
...@@ -368,4 +368,4 @@ ...@@ -368,4 +368,4 @@
<Import Project="..\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets" Condition="Exists('..\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets')" /> <Import Project="..\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets" Condition="Exists('..\packages\Microsoft.SourceLink.Common.1.0.0\build\Microsoft.SourceLink.Common.targets')" />
<Import Project="..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets" Condition="Exists('..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets')" /> <Import Project="..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets" Condition="Exists('..\packages\Microsoft.SourceLink.GitHub.1.0.0\build\Microsoft.SourceLink.GitHub.targets')" />
</ImportGroup> </ImportGroup>
</Project> </Project>
\ No newline at end of file
...@@ -134,10 +134,7 @@ Task<double>^ CefBrowserHostWrapper::GetZoomLevelAsync() ...@@ -134,10 +134,7 @@ Task<double>^ CefBrowserHostWrapper::GetZoomLevelAsync()
if (CefCurrentlyOn(TID_UI)) if (CefCurrentlyOn(TID_UI))
{ {
auto taskSource = gcnew TaskCompletionSource<double>(); return Task::FromResult(GetZoomLevelOnUI());
CefSharp::Internals::TaskExtensions::TrySetResultAsync<double>(taskSource, GetZoomLevelOnUI());
return taskSource->Task;
} }
return Cef::UIThreadTaskFactory->StartNew(gcnew Func<double>(this, &CefBrowserHostWrapper::GetZoomLevelOnUI)); return Cef::UIThreadTaskFactory->StartNew(gcnew Func<double>(this, &CefBrowserHostWrapper::GetZoomLevelOnUI));
} }
......
...@@ -1489,7 +1489,7 @@ namespace CefSharp ...@@ -1489,7 +1489,7 @@ namespace CefSharp
response->Message = StringUtils::ToClr(argList->GetString(2)); response->Message = StringUtils::ToClr(argList->GetString(2));
} }
CefSharp::Internals::TaskExtensions::TrySetResultAsync<JavascriptResponse^>(pendingTask, response); pendingTask->TrySetResult(response);
} }
handled = true; handled = true;
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net452</TargetFramework> <TargetFramework>net462</TargetFramework>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>CefSharp</RootNamespace> <RootNamespace>CefSharp</RootNamespace>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
......
...@@ -138,7 +138,7 @@ namespace CefSharp.DevTools ...@@ -138,7 +138,7 @@ namespace CefSharp.DevTools
throw new ObjectDisposedException(nameof(IBrowser)); throw new ObjectDisposedException(nameof(IBrowser));
} }
var taskCompletionSource = new TaskCompletionSource<T>(); var taskCompletionSource = new TaskCompletionSource<T>(TaskCreationOptions.RunContinuationsAsynchronously);
var methodResultContext = new DevToolsMethodResponseContext( var methodResultContext = new DevToolsMethodResponseContext(
type: typeof(T), type: typeof(T),
...@@ -332,7 +332,7 @@ namespace CefSharp.DevTools ...@@ -332,7 +332,7 @@ namespace CefSharp.DevTools
/// <summary> /// <summary>
/// Deserialize the JSON stream into a .Net object. /// Deserialize the JSON stream into a .Net object.
/// For .Net Core/.Net 5.0 uses System.Text.Json /// For .Net Core/.Net 5.0 uses System.Text.Json
/// for .Net 4.5.2 uses System.Runtime.Serialization.Json /// for .Net 4.6.2 uses System.Runtime.Serialization.Json
/// </summary> /// </summary>
/// <typeparam name="T">Object type</typeparam> /// <typeparam name="T">Object type</typeparam>
/// <param name="eventName">event Name</param> /// <param name="eventName">event Name</param>
...@@ -359,7 +359,7 @@ namespace CefSharp.DevTools ...@@ -359,7 +359,7 @@ namespace CefSharp.DevTools
/// <summary> /// <summary>
/// Deserialize the JSON stream into a .Net object. /// Deserialize the JSON stream into a .Net object.
/// For .Net Core/.Net 5.0 uses System.Text.Json /// For .Net Core/.Net 5.0 uses System.Text.Json
/// for .Net 4.5.2 uses System.Runtime.Serialization.Json /// for .Net 4.6.2 uses System.Runtime.Serialization.Json
/// </summary> /// </summary>
/// <typeparam name="T">Object type</typeparam> /// <typeparam name="T">Object type</typeparam>
/// <param name="stream">JSON stream</param> /// <param name="stream">JSON stream</param>
...@@ -372,7 +372,7 @@ namespace CefSharp.DevTools ...@@ -372,7 +372,7 @@ namespace CefSharp.DevTools
/// <summary> /// <summary>
/// Deserialize the JSON stream into a .Net object. /// Deserialize the JSON stream into a .Net object.
/// For .Net Core/.Net 5.0 uses System.Text.Json /// For .Net Core/.Net 5.0 uses System.Text.Json
/// for .Net 4.5.2 uses System.Runtime.Serialization.Json /// for .Net 4.6.2 uses System.Runtime.Serialization.Json
/// </summary> /// </summary>
/// <param name="type">Object type</param> /// <param name="type">Object type</param>
/// <param name="stream">JSON stream</param> /// <param name="stream">JSON stream</param>
......
...@@ -39,13 +39,13 @@ namespace CefSharp ...@@ -39,13 +39,13 @@ namespace CefSharp
return Task.FromResult<NavigationEntry>(entry); return Task.FromResult<NavigationEntry>(entry);
} }
var tcs = new TaskCompletionSource<NavigationEntry>(); var tcs = new TaskCompletionSource<NavigationEntry>(TaskCreationOptions.RunContinuationsAsynchronously);
Cef.UIThreadTaskFactory.StartNew(delegate Cef.UIThreadTaskFactory.StartNew(delegate
{ {
var entry = host.GetVisibleNavigationEntry(); var entry = host.GetVisibleNavigationEntry();
tcs.TrySetResultAsync(entry); tcs.TrySetResult(entry);
}); });
return tcs.Task; return tcs.Task;
...@@ -107,7 +107,7 @@ namespace CefSharp ...@@ -107,7 +107,7 @@ namespace CefSharp
throw new Exception("Frame is invalid, unable to continue."); throw new Exception("Frame is invalid, unable to continue.");
} }
var taskCompletionSource = new TaskCompletionSource<byte[]>(); var taskCompletionSource = new TaskCompletionSource<byte[]>(TaskCreationOptions.RunContinuationsAsynchronously);
//Can be created on any valid CEF Thread, here we'll use the CEF UI Thread //Can be created on any valid CEF Thread, here we'll use the CEF UI Thread
Cef.UIThreadTaskFactory.StartNew(delegate Cef.UIThreadTaskFactory.StartNew(delegate
...@@ -129,11 +129,11 @@ namespace CefSharp ...@@ -129,11 +129,11 @@ namespace CefSharp
{ {
if (req.RequestStatus == UrlRequestStatus.Success) if (req.RequestStatus == UrlRequestStatus.Success)
{ {
taskCompletionSource.TrySetResultAsync(memoryStream.ToArray()); taskCompletionSource.TrySetResult(memoryStream.ToArray());
} }
else else
{ {
taskCompletionSource.TrySetExceptionAsync(new Exception("RequestStatus:" + req.RequestStatus + ";StatusCode:" + req.Response.StatusCode)); taskCompletionSource.TrySetException(new Exception("RequestStatus:" + req.RequestStatus + ";StatusCode:" + req.Response.StatusCode));
} }
}) })
.Build(); .Build();
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net452;net462</TargetFrameworks> <TargetFrameworks>net462</TargetFrameworks>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\CefSharp.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\CefSharp.snk</AssemblyOriginatorKeyFile>
......
...@@ -389,11 +389,11 @@ namespace CefSharp.OffScreen ...@@ -389,11 +389,11 @@ namespace CefSharp.OffScreen
/// </returns> /// </returns>
public Task<IBrowser> CreateBrowserAsync(IWindowInfo windowInfo = null, IBrowserSettings browserSettings = null) public Task<IBrowser> CreateBrowserAsync(IWindowInfo windowInfo = null, IBrowserSettings browserSettings = null)
{ {
var tcs = new TaskCompletionSource<IBrowser>(); var tcs = new TaskCompletionSource<IBrowser>(TaskCreationOptions.RunContinuationsAsynchronously);
onAfterBrowserCreatedDelegate += new Action<IBrowser>(b => onAfterBrowserCreatedDelegate += new Action<IBrowser>(b =>
{ {
tcs.TrySetResultAsync(b); tcs.TrySetResult(b);
}); });
try try
...@@ -402,7 +402,7 @@ namespace CefSharp.OffScreen ...@@ -402,7 +402,7 @@ namespace CefSharp.OffScreen
} }
catch(Exception ex) catch(Exception ex)
{ {
tcs.TrySetExceptionAsync(ex); tcs.TrySetException(ex);
} }
return tcs.Task; return tcs.Task;
...@@ -520,7 +520,7 @@ namespace CefSharp.OffScreen ...@@ -520,7 +520,7 @@ namespace CefSharp.OffScreen
// Try our luck and see if there is already a screenshot, to save us creating a new thread for nothing. // Try our luck and see if there is already a screenshot, to save us creating a new thread for nothing.
var screenshot = ScreenshotOrNull(blend); var screenshot = ScreenshotOrNull(blend);
var completionSource = new TaskCompletionSource<Bitmap>(); var completionSource = new TaskCompletionSource<Bitmap>(TaskCreationOptions.RunContinuationsAsynchronously);
if (screenshot == null || ignoreExistingScreenshot) if (screenshot == null || ignoreExistingScreenshot)
{ {
...@@ -539,7 +539,7 @@ namespace CefSharp.OffScreen ...@@ -539,7 +539,7 @@ namespace CefSharp.OffScreen
} }
else else
{ {
completionSource.TrySetResultAsync(ScreenshotOrNull(blend)); completionSource.TrySetResult(ScreenshotOrNull(blend));
} }
}; };
...@@ -547,7 +547,7 @@ namespace CefSharp.OffScreen ...@@ -547,7 +547,7 @@ namespace CefSharp.OffScreen
} }
else else
{ {
completionSource.TrySetResultAsync(screenshot); completionSource.TrySetResult(screenshot);
} }
return completionSource.Task; return completionSource.Task;
...@@ -640,7 +640,7 @@ namespace CefSharp.OffScreen ...@@ -640,7 +640,7 @@ namespace CefSharp.OffScreen
var scaledWidth = (int)(width * DeviceScaleFactor); var scaledWidth = (int)(width * DeviceScaleFactor);
var scaledHeight = (int)(height * DeviceScaleFactor); var scaledHeight = (int)(height * DeviceScaleFactor);
var tcs = new TaskCompletionSource<bool>(); var tcs = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
EventHandler<OnPaintEventArgs> handler = null; EventHandler<OnPaintEventArgs> handler = null;
handler = (s, e) => handler = (s, e) =>
...@@ -649,7 +649,7 @@ namespace CefSharp.OffScreen ...@@ -649,7 +649,7 @@ namespace CefSharp.OffScreen
{ {
AfterPaint -= handler; AfterPaint -= handler;
tcs.TrySetResultAsync(true); tcs.TrySetResult(true);
} }
}; };
...@@ -692,7 +692,6 @@ namespace CefSharp.OffScreen ...@@ -692,7 +692,6 @@ namespace CefSharp.OffScreen
} }
} }
#if NETCOREAPP || NET462
/// <summary> /// <summary>
/// Waits for the page rendering to be idle for <paramref name="idleTimeInMs"/>. /// Waits for the page rendering to be idle for <paramref name="idleTimeInMs"/>.
/// Rendering is considered to be idle when no <see cref="Paint"/> events have occured /// Rendering is considered to be idle when no <see cref="Paint"/> events have occured
...@@ -750,7 +749,6 @@ namespace CefSharp.OffScreen ...@@ -750,7 +749,6 @@ namespace CefSharp.OffScreen
throw; throw;
} }
} }
#endif
/// <summary> /// <summary>
/// The javascript object repository, one repository per ChromiumWebBrowser instance. /// The javascript object repository, one repository per ChromiumWebBrowser instance.
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net452;net462</TargetFrameworks> <TargetFrameworks>net462</TargetFrameworks>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\CefSharp.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\CefSharp.snk</AssemblyOriginatorKeyFile>
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net452;net462</TargetFrameworks> <TargetFrameworks>net462</TargetFrameworks>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
......
...@@ -1776,7 +1776,6 @@ namespace CefSharp.Wpf ...@@ -1776,7 +1776,6 @@ namespace CefSharp.Wpf
} }
} }
#if NETCOREAPP || NET462
/// <inheritdoc/> /// <inheritdoc/>
protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi) protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
{ {
...@@ -1784,7 +1783,6 @@ namespace CefSharp.Wpf ...@@ -1784,7 +1783,6 @@ namespace CefSharp.Wpf
base.OnDpiChanged(oldDpi, newDpi); base.OnDpiChanged(oldDpi, newDpi);
} }
#endif
private void OnWindowStateChanged(object sender, EventArgs e) private void OnWindowStateChanged(object sender, EventArgs e)
{ {
...@@ -2638,8 +2636,6 @@ namespace CefSharp.Wpf ...@@ -2638,8 +2636,6 @@ namespace CefSharp.Wpf
/// correspond to 96, 120, 144, 192 DPI (referred to as 100%, 125%, 150%, 200% in the Windows GUI). /// correspond to 96, 120, 144, 192 DPI (referred to as 100%, 125%, 150%, 200% in the Windows GUI).
/// </summary> /// </summary>
/// <param name="newDpi">new DPI</param> /// <param name="newDpi">new DPI</param>
/// <remarks>.Net 4.6.2 adds HwndSource.DpiChanged which could be used to automatically
/// handle DPI change, unfortunately we still target .Net 4.5.2</remarks>
public virtual void NotifyDpiChange(float newDpi) public virtual void NotifyDpiChange(float newDpi)
{ {
//Do nothing //Do nothing
...@@ -2680,7 +2676,6 @@ namespace CefSharp.Wpf ...@@ -2680,7 +2676,6 @@ namespace CefSharp.Wpf
} }
} }
#if NETCOREAPP || NET462
/// <summary> /// <summary>
/// Waits for the page rendering to be idle for <paramref name="idleTimeInMs"/>. /// Waits for the page rendering to be idle for <paramref name="idleTimeInMs"/>.
/// Rendering is considered to be idle when no <see cref="Paint"/> events have occured /// Rendering is considered to be idle when no <see cref="Paint"/> events have occured
...@@ -2738,7 +2733,6 @@ namespace CefSharp.Wpf ...@@ -2738,7 +2733,6 @@ namespace CefSharp.Wpf
throw; throw;
} }
} }
#endif
/// <summary> /// <summary>
/// Legacy keyboard handler uses WindowProc callback interceptor to forward keypress events /// Legacy keyboard handler uses WindowProc callback interceptor to forward keypress events
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using CefSharp.Internals;
namespace CefSharp namespace CefSharp
{ {
...@@ -22,14 +21,14 @@ namespace CefSharp ...@@ -22,14 +21,14 @@ namespace CefSharp
/// </summary> /// </summary>
public TaskCompletionCallback() public TaskCompletionCallback()
{ {
taskCompletionSource = new TaskCompletionSource<bool>(); taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
} }
void ICompletionCallback.OnComplete() void ICompletionCallback.OnComplete()
{ {
onComplete = true; onComplete = true;
taskCompletionSource.TrySetResultAsync(true); taskCompletionSource.TrySetResult(true);
} }
/// <summary> /// <summary>
...@@ -50,11 +49,10 @@ namespace CefSharp ...@@ -50,11 +49,10 @@ namespace CefSharp
var task = taskCompletionSource.Task; var task = taskCompletionSource.Task;
//If onComplete is false then ICompletionCallback.OnComplete was never called, //If onComplete is false then ICompletionCallback.OnComplete was never called,
//so we'll set the result to false. Calling TrySetResultAsync multiple times //so we'll set the result to false.
//can result in the issue outlined in https://github.com/cefsharp/CefSharp/pull/2349
if (onComplete == false && task.IsCompleted == false) if (onComplete == false && task.IsCompleted == false)
{ {
taskCompletionSource.TrySetResultAsync(false); taskCompletionSource.TrySetResult(false);
} }
isDisposed = true; isDisposed = true;
......
...@@ -27,14 +27,14 @@ namespace CefSharp ...@@ -27,14 +27,14 @@ namespace CefSharp
/// </summary> /// </summary>
public TaskDeleteCookiesCallback() public TaskDeleteCookiesCallback()
{ {
taskCompletionSource = new TaskCompletionSource<int>(); taskCompletionSource = new TaskCompletionSource<int>(TaskCreationOptions.RunContinuationsAsynchronously);
} }
void IDeleteCookiesCallback.OnComplete(int numDeleted) void IDeleteCookiesCallback.OnComplete(int numDeleted)
{ {
onComplete = true; onComplete = true;
taskCompletionSource.TrySetResultAsync(numDeleted); taskCompletionSource.TrySetResult(numDeleted);
} }
/// <summary> /// <summary>
...@@ -54,11 +54,10 @@ namespace CefSharp ...@@ -54,11 +54,10 @@ namespace CefSharp
var task = taskCompletionSource.Task; var task = taskCompletionSource.Task;
//If onComplete is false then IDeleteCookiesCallback.OnComplete was never called, //If onComplete is false then IDeleteCookiesCallback.OnComplete was never called,
//so we'll set the result to false. Calling TrySetResultAsync multiple times //so we'll set the result to false.
//can result in the issue outlined in https://github.com/cefsharp/CefSharp/pull/2349
if (onComplete == false && task.IsCompleted == false) if (onComplete == false && task.IsCompleted == false)
{ {
taskCompletionSource.TrySetResultAsync(InvalidNoOfCookiesDeleted); taskCompletionSource.TrySetResult(InvalidNoOfCookiesDeleted);
} }
isDisposed = true; isDisposed = true;
......
...@@ -13,7 +13,7 @@ namespace CefSharp ...@@ -13,7 +13,7 @@ namespace CefSharp
/// </summary> /// </summary>
public sealed class TaskPrintToPdfCallback : IPrintToPdfCallback public sealed class TaskPrintToPdfCallback : IPrintToPdfCallback
{ {
private readonly TaskCompletionSource<bool> taskCompletionSource = new TaskCompletionSource<bool>(); private readonly TaskCompletionSource<bool> taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
private volatile bool isDisposed; private volatile bool isDisposed;
private bool onComplete; //Only ever accessed on the same CEF thread, so no need for thread safety private bool onComplete; //Only ever accessed on the same CEF thread, so no need for thread safety
...@@ -29,7 +29,7 @@ namespace CefSharp ...@@ -29,7 +29,7 @@ namespace CefSharp
{ {
onComplete = true; onComplete = true;
taskCompletionSource.TrySetResultAsync(ok); taskCompletionSource.TrySetResult(ok);
} }
bool IPrintToPdfCallback.IsDisposed bool IPrintToPdfCallback.IsDisposed
...@@ -42,11 +42,10 @@ namespace CefSharp ...@@ -42,11 +42,10 @@ namespace CefSharp
var task = taskCompletionSource.Task; var task = taskCompletionSource.Task;
//If onComplete is false then IPrintToPdfCallback.OnPdfPrintFinished was never called, //If onComplete is false then IPrintToPdfCallback.OnPdfPrintFinished was never called,
//so we'll set the result to false. Calling TrySetResultAsync multiple times //so we'll set the result to false.
//can result in the issue outlined in https://github.com/cefsharp/CefSharp/pull/2349
if (onComplete == false && task.IsCompleted == false) if (onComplete == false && task.IsCompleted == false)
{ {
taskCompletionSource.TrySetResultAsync(false); taskCompletionSource.TrySetResult(false);
} }
isDisposed = true; isDisposed = true;
......
...@@ -23,14 +23,14 @@ namespace CefSharp ...@@ -23,14 +23,14 @@ namespace CefSharp
/// </summary> /// </summary>
public TaskResolveCallback() public TaskResolveCallback()
{ {
taskCompletionSource = new TaskCompletionSource<ResolveCallbackResult>(); taskCompletionSource = new TaskCompletionSource<ResolveCallbackResult>(TaskCreationOptions.RunContinuationsAsynchronously);
} }
void IResolveCallback.OnResolveCompleted(CefErrorCode result, IList<string> resolvedIpAddresses) void IResolveCallback.OnResolveCompleted(CefErrorCode result, IList<string> resolvedIpAddresses)
{ {
onComplete = true; onComplete = true;
taskCompletionSource.TrySetResultAsync(new ResolveCallbackResult(result, resolvedIpAddresses)); taskCompletionSource.TrySetResult(new ResolveCallbackResult(result, resolvedIpAddresses));
} }
bool IResolveCallback.IsDisposed bool IResolveCallback.IsDisposed
...@@ -51,11 +51,10 @@ namespace CefSharp ...@@ -51,11 +51,10 @@ namespace CefSharp
var task = taskCompletionSource.Task; var task = taskCompletionSource.Task;
//If onComplete is false then IResolveCallback.OnResolveCompleted was never called, //If onComplete is false then IResolveCallback.OnResolveCompleted was never called,
//so we'll set the result to false. Calling TrySetResultAsync multiple times //so we'll set the result to false.
//can result in the issue outlined in https://github.com/cefsharp/CefSharp/pull/2349
if (onComplete == false && task.IsCompleted == false) if (onComplete == false && task.IsCompleted == false)
{ {
taskCompletionSource.TrySetResultAsync(new ResolveCallbackResult(CefErrorCode.Unexpected, null)); taskCompletionSource.TrySetResult(new ResolveCallbackResult(CefErrorCode.Unexpected, null));
} }
isDisposed = true; isDisposed = true;
......
...@@ -22,14 +22,14 @@ namespace CefSharp ...@@ -22,14 +22,14 @@ namespace CefSharp
/// </summary> /// </summary>
public TaskSetCookieCallback() public TaskSetCookieCallback()
{ {
taskCompletionSource = new TaskCompletionSource<bool>(); taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
} }
void ISetCookieCallback.OnComplete(bool success) void ISetCookieCallback.OnComplete(bool success)
{ {
onComplete = true; onComplete = true;
taskCompletionSource.TrySetResultAsync(success); taskCompletionSource.TrySetResult(success);
} }
/// <summary> /// <summary>
...@@ -50,11 +50,10 @@ namespace CefSharp ...@@ -50,11 +50,10 @@ namespace CefSharp
var task = taskCompletionSource.Task; var task = taskCompletionSource.Task;
//If onComplete is false then ISetCookieCallback.OnComplete was never called, //If onComplete is false then ISetCookieCallback.OnComplete was never called,
//so we'll set the result to false. Calling TrySetResultAsync multiple times //so we'll set the result to false.
//can result in the issue outlined in https://github.com/cefsharp/CefSharp/pull/2349
if (onComplete == false && task.IsCompleted == false) if (onComplete == false && task.IsCompleted == false)
{ {
taskCompletionSource.TrySetResultAsync(false); taskCompletionSource.TrySetResult(false);
} }
isDisposed = true; isDisposed = true;
......
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net452</TargetFramework> <TargetFramework>net462</TargetFramework>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>
......
...@@ -51,7 +51,7 @@ namespace CefSharp.WinForms ...@@ -51,7 +51,7 @@ namespace CefSharp.WinForms
/// <summary> /// <summary>
/// Initial browser load task complection source /// Initial browser load task complection source
/// </summary> /// </summary>
private TaskCompletionSource<LoadUrlAsyncResponse> initialLoadTaskCompletionSource = new TaskCompletionSource<LoadUrlAsyncResponse>(); private TaskCompletionSource<LoadUrlAsyncResponse> initialLoadTaskCompletionSource = new TaskCompletionSource<LoadUrlAsyncResponse>(TaskCreationOptions.RunContinuationsAsynchronously);
/// <summary> /// <summary>
/// Initial browser load action /// Initial browser load action
...@@ -458,7 +458,7 @@ namespace CefSharp.WinForms ...@@ -458,7 +458,7 @@ namespace CefSharp.WinForms
statusCode = -1; statusCode = -1;
} }
initialLoadTaskCompletionSource.TrySetResultAsync(new LoadUrlAsyncResponse(CefErrorCode.None, statusCode)); initialLoadTaskCompletionSource.TrySetResult(new LoadUrlAsyncResponse(CefErrorCode.None, statusCode));
} }
else if (errorCode.HasValue) else if (errorCode.HasValue)
{ {
...@@ -471,7 +471,7 @@ namespace CefSharp.WinForms ...@@ -471,7 +471,7 @@ namespace CefSharp.WinForms
initialLoadAction = null; initialLoadAction = null;
initialLoadTaskCompletionSource.TrySetResultAsync(new LoadUrlAsyncResponse(errorCode.Value, -1)); initialLoadTaskCompletionSource.TrySetResult(new LoadUrlAsyncResponse(errorCode.Value, -1));
} }
} }
......
...@@ -33,7 +33,7 @@ namespace CefSharp.Internals ...@@ -33,7 +33,7 @@ namespace CefSharp.Internals
/// <returns>The unique id of the newly created pending task and the newly created <see cref="TaskCompletionSource{TResult}"/>.</returns> /// <returns>The unique id of the newly created pending task and the newly created <see cref="TaskCompletionSource{TResult}"/>.</returns>
public KeyValuePair<long, TaskCompletionSource<TResult>> CreatePendingTask(TimeSpan? timeout = null) public KeyValuePair<long, TaskCompletionSource<TResult>> CreatePendingTask(TimeSpan? timeout = null)
{ {
var taskCompletionSource = new TaskCompletionSource<TResult>(); var taskCompletionSource = new TaskCompletionSource<TResult>(TaskCreationOptions.RunContinuationsAsynchronously);
var id = Interlocked.Increment(ref lastId); var id = Interlocked.Increment(ref lastId);
pendingTasks.TryAdd(id, taskCompletionSource); pendingTasks.TryAdd(id, taskCompletionSource);
...@@ -54,7 +54,7 @@ namespace CefSharp.Internals ...@@ -54,7 +54,7 @@ namespace CefSharp.Internals
/// <returns>The unique id of the newly created pending task and the newly created <see cref="TaskCompletionSource{TResult}"/>.</returns> /// <returns>The unique id of the newly created pending task and the newly created <see cref="TaskCompletionSource{TResult}"/>.</returns>
public KeyValuePair<long, TaskCompletionSource<TResult>> CreateJavascriptCallbackPendingTask(long id, TimeSpan? timeout = null) public KeyValuePair<long, TaskCompletionSource<TResult>> CreateJavascriptCallbackPendingTask(long id, TimeSpan? timeout = null)
{ {
var taskCompletionSource = new TaskCompletionSource<TResult>(); var taskCompletionSource = new TaskCompletionSource<TResult>(TaskCreationOptions.RunContinuationsAsynchronously);
callbackPendingTasks.TryAdd(id, taskCompletionSource); callbackPendingTasks.TryAdd(id, taskCompletionSource);
......
...@@ -15,64 +15,6 @@ namespace CefSharp.Internals ...@@ -15,64 +15,6 @@ namespace CefSharp.Internals
/// </summary> /// </summary>
public static class TaskExtensions public static class TaskExtensions
{ {
/// <summary>Creates a new Task that mirrors the supplied task but that will be canceled after the specified timeout.</summary>
/// <typeparam name="TResult">Specifies the type of data contained in the task.</typeparam>
/// <param name="task">The task.</param>
/// <param name="timeout">The timeout.</param>
/// <returns>The new Task that may time out.</returns>
public static Task<TResult> WithTimeout<TResult>(this Task<TResult> task, TimeSpan timeout)
{
var result = new TaskCompletionSource<TResult>(task.AsyncState);
var timer = new Timer(state => ((TaskCompletionSource<TResult>)state).TrySetCanceled(), result, timeout, TimeSpan.FromMilliseconds(-1));
task.ContinueWith(t =>
{
timer.Dispose();
result.TrySetFromTask(t);
}, TaskContinuationOptions.ExecuteSynchronously);
return result.Task;
}
/// <summary>Attempts to transfer the result of a Task to the TaskCompletionSource.</summary>
/// <typeparam name="TResult">Specifies the type of the result.</typeparam>
/// <param name="resultSetter">The TaskCompletionSource.</param>
/// <param name="task">The task whose completion results should be transfered.</param>
/// <returns>Whether the transfer could be completed.</returns>
public static bool TrySetFromTask<TResult>(this TaskCompletionSource<TResult> resultSetter, Task task)
{
switch (task.Status)
{
case TaskStatus.RanToCompletion:
return resultSetter.TrySetResult(task is Task<TResult> ? ((Task<TResult>)task).Result : default(TResult));
case TaskStatus.Faulted:
return resultSetter.TrySetException(task.Exception.InnerExceptions);
case TaskStatus.Canceled:
return resultSetter.TrySetCanceled();
default:
throw new InvalidOperationException("The task was not completed.");
}
}
/// <summary>Attempts to transfer the result of a Task to the TaskCompletionSource.</summary>
/// <typeparam name="TResult">Specifies the type of the result.</typeparam>
/// <param name="resultSetter">The TaskCompletionSource.</param>
/// <param name="task">The task whose completion results should be transfered.</param>
/// <returns>Whether the transfer could be completed.</returns>
public static bool TrySetFromTask<TResult>(this TaskCompletionSource<TResult> resultSetter, Task<TResult> task)
{
return TrySetFromTask(resultSetter, (Task)task);
}
public static Task<T> FromResult<T>(T value)
{
var tcs = new TaskCompletionSource<T>();
tcs.SetResult(value);
return tcs.Task;
}
public static TaskCompletionSource<TResult> WithTimeout<TResult>(this TaskCompletionSource<TResult> taskCompletionSource, TimeSpan timeout)
{
return WithTimeout(taskCompletionSource, timeout, null);
}
public static TaskCompletionSource<TResult> WithTimeout<TResult>(this TaskCompletionSource<TResult> taskCompletionSource, TimeSpan timeout, Action cancelled) public static TaskCompletionSource<TResult> WithTimeout<TResult>(this TaskCompletionSource<TResult> taskCompletionSource, TimeSpan timeout, Action cancelled)
{ {
Timer timer = null; Timer timer = null;
...@@ -91,49 +33,5 @@ namespace CefSharp.Internals ...@@ -91,49 +33,5 @@ namespace CefSharp.Internals
return taskCompletionSource; return taskCompletionSource;
} }
/// <summary>
/// Set the TaskCompletionSource in an async fashion. This prevents the Task Continuation being executed sync on the same thread
/// This is required otherwise continuations will happen on CEF UI threads
/// </summary>
/// <typeparam name="TResult">Generic param</typeparam>
/// <param name="taskCompletionSource">tcs</param>
/// <param name="result">result</param>
public static void TrySetResultAsync<TResult>(this TaskCompletionSource<TResult> taskCompletionSource, TResult result)
{
Task.Factory.StartNew(delegate
{
taskCompletionSource.TrySetResult(result);
}, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
}
/// <summary>
/// Calls <see cref="TaskCompletionSource{TResult}.TrySetException(Exception)"/> in an async fashion. This prevents the Task Continuation being executed sync on the same thread
/// This is required otherwise continuations will happen on CEF UI threads
/// </summary>
/// <typeparam name="TResult">Generic param</typeparam>
/// <param name="taskCompletionSource">tcs</param>
/// <param name="ex">exception</param>
public static void TrySetExceptionAsync<TResult>(this TaskCompletionSource<TResult> taskCompletionSource, Exception ex)
{
Task.Factory.StartNew(delegate
{
taskCompletionSource.TrySetException(ex);
}, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
}
/// <summary>
/// Calls <see cref="TaskCompletionSource{TResult}.TrySetCanceled()"/> in an async fashion. This prevents the Task Continuation being executed sync on the same thread
/// This is required otherwise continuations will happen on CEF UI threads
/// </summary>
/// <typeparam name="TResult">Generic param</typeparam>
/// <param name="taskCompletionSource">tcs</param>
public static void TrySetCanceledAsync<TResult>(this TaskCompletionSource<TResult> taskCompletionSource)
{
Task.Factory.StartNew(delegate
{
taskCompletionSource.TrySetCanceled();
}, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
}
} }
} }
...@@ -23,7 +23,7 @@ namespace CefSharp ...@@ -23,7 +23,7 @@ namespace CefSharp
/// <returns>List of objects that were bound</returns> /// <returns>List of objects that were bound</returns>
public static Task<IList<string>> EnsureObjectBoundAsync(this IWebBrowser browser, params string[] names) public static Task<IList<string>> EnsureObjectBoundAsync(this IWebBrowser browser, params string[] names)
{ {
var objBoundTasks = new TaskCompletionSource<IList<string>>(); var objBoundTasks = new TaskCompletionSource<IList<string>>(TaskCreationOptions.RunContinuationsAsynchronously);
EventHandler<JavascriptBindingMultipleCompleteEventArgs> handler = null; EventHandler<JavascriptBindingMultipleCompleteEventArgs> handler = null;
handler = (sender, args) => handler = (sender, args) =>
...@@ -34,11 +34,11 @@ namespace CefSharp ...@@ -34,11 +34,11 @@ namespace CefSharp
var allObjectsBound = names.ToList().SequenceEqual(args.ObjectNames); var allObjectsBound = names.ToList().SequenceEqual(args.ObjectNames);
if (allObjectsBound) if (allObjectsBound)
{ {
objBoundTasks.SetResult(args.ObjectNames); objBoundTasks.TrySetResult(args.ObjectNames);
} }
else else
{ {
objBoundTasks.SetException(new Exception("Not all objects were bound successfully, bound objects were " + string.Join(",", args.ObjectNames))); objBoundTasks.TrySetException(new Exception("Not all objects were bound successfully, bound objects were " + string.Join(",", args.ObjectNames)));
} }
}; };
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using CefSharp.Internals;
namespace CefSharp namespace CefSharp
{ {
...@@ -23,7 +22,7 @@ namespace CefSharp ...@@ -23,7 +22,7 @@ namespace CefSharp
/// </summary> /// </summary>
public TaskCookieVisitor() public TaskCookieVisitor()
{ {
taskCompletionSource = new TaskCompletionSource<List<Cookie>>(); taskCompletionSource = new TaskCompletionSource<List<Cookie>>(TaskCreationOptions.RunContinuationsAsynchronously);
list = new List<Cookie>(); list = new List<Cookie>();
} }
...@@ -34,8 +33,7 @@ namespace CefSharp ...@@ -34,8 +33,7 @@ namespace CefSharp
if (count == (total - 1)) if (count == (total - 1))
{ {
//Set the result on the ThreadPool so the Task continuation is not run on the CEF UI Thread taskCompletionSource.TrySetResult(list);
taskCompletionSource.TrySetResultAsync(list);
} }
return true; return true;
...@@ -46,8 +44,7 @@ namespace CefSharp ...@@ -46,8 +44,7 @@ namespace CefSharp
{ {
if (list != null && list.Count == 0) if (list != null && list.Count == 0)
{ {
//Set the result on the ThreadPool so the Task continuation is not run on the CEF UI Thread taskCompletionSource.TrySetResult(list);
taskCompletionSource.TrySetResultAsync(list);
} }
list = null; list = null;
......
...@@ -23,7 +23,7 @@ namespace CefSharp ...@@ -23,7 +23,7 @@ namespace CefSharp
/// </summary> /// </summary>
public TaskNavigationEntryVisitor() public TaskNavigationEntryVisitor()
{ {
taskCompletionSource = new TaskCompletionSource<List<NavigationEntry>>(); taskCompletionSource = new TaskCompletionSource<List<NavigationEntry>>(TaskCreationOptions.RunContinuationsAsynchronously);
list = new List<NavigationEntry>(); list = new List<NavigationEntry>();
} }
...@@ -40,8 +40,7 @@ namespace CefSharp ...@@ -40,8 +40,7 @@ namespace CefSharp
{ {
if (list != null) if (list != null)
{ {
//Set the result on the ThreadPool so the Task continuation is not run on the CEF UI Thread taskCompletionSource.TrySetResult(list);
taskCompletionSource.TrySetResultAsync(list);
} }
list = null; list = null;
......
...@@ -21,7 +21,7 @@ namespace CefSharp ...@@ -21,7 +21,7 @@ namespace CefSharp
/// </summary> /// </summary>
public TaskStringVisitor() public TaskStringVisitor()
{ {
taskCompletionSource = new TaskCompletionSource<string>(); taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
} }
/// <summary> /// <summary>
...@@ -30,7 +30,7 @@ namespace CefSharp ...@@ -30,7 +30,7 @@ namespace CefSharp
/// <param name="str">string (result of async execution)</param> /// <param name="str">string (result of async execution)</param>
void IStringVisitor.Visit(string str) void IStringVisitor.Visit(string str)
{ {
taskCompletionSource.TrySetResultAsync(str); taskCompletionSource.TrySetResult(str);
} }
/// <summary> /// <summary>
......
...@@ -424,7 +424,7 @@ namespace CefSharp ...@@ -424,7 +424,7 @@ namespace CefSharp
throw new ArgumentNullException(nameof(url)); throw new ArgumentNullException(nameof(url));
} }
var tcs = new TaskCompletionSource<LoadUrlAsyncResponse>(); var tcs = new TaskCompletionSource<LoadUrlAsyncResponse>(TaskCreationOptions.RunContinuationsAsynchronously);
EventHandler<LoadErrorEventArgs> loadErrorHandler = null; EventHandler<LoadErrorEventArgs> loadErrorHandler = null;
EventHandler<LoadingStateChangedEventArgs> loadingStateChangeHandler = null; EventHandler<LoadingStateChangedEventArgs> loadingStateChangeHandler = null;
...@@ -447,7 +447,7 @@ namespace CefSharp ...@@ -447,7 +447,7 @@ namespace CefSharp
//Ensure our continuation is executed on the ThreadPool //Ensure our continuation is executed on the ThreadPool
//For the .Net Core implementation we could use //For the .Net Core implementation we could use
//TaskCreationOptions.RunContinuationsAsynchronously //TaskCreationOptions.RunContinuationsAsynchronously
tcs.TrySetResultAsync(new LoadUrlAsyncResponse(args.ErrorCode, -1)); tcs.TrySetResult(new LoadUrlAsyncResponse(args.ErrorCode, -1));
}; };
loadingStateChangeHandler = (sender, args) => loadingStateChangeHandler = (sender, args) =>
...@@ -478,7 +478,7 @@ namespace CefSharp ...@@ -478,7 +478,7 @@ namespace CefSharp
//Ensure our continuation is executed on the ThreadPool //Ensure our continuation is executed on the ThreadPool
//For the .Net Core implementation we could use //For the .Net Core implementation we could use
//TaskCreationOptions.RunContinuationsAsynchronously //TaskCreationOptions.RunContinuationsAsynchronously
tcs.TrySetResultAsync(new LoadUrlAsyncResponse(statusCode == -1 ? CefErrorCode.Failed : CefErrorCode.None, statusCode)); tcs.TrySetResult(new LoadUrlAsyncResponse(statusCode == -1 ? CefErrorCode.Failed : CefErrorCode.None, statusCode));
} }
}; };
...@@ -520,7 +520,7 @@ namespace CefSharp ...@@ -520,7 +520,7 @@ namespace CefSharp
{ {
ThrowExceptionIfChromiumWebBrowserDisposed(chromiumWebBrowser); ThrowExceptionIfChromiumWebBrowserDisposed(chromiumWebBrowser);
var tcs = new TaskCompletionSource<WaitForNavigationAsyncResponse>(); var tcs = new TaskCompletionSource<WaitForNavigationAsyncResponse>(TaskCreationOptions.RunContinuationsAsynchronously);
EventHandler<LoadErrorEventArgs> loadErrorHandler = null; EventHandler<LoadErrorEventArgs> loadErrorHandler = null;
EventHandler<LoadingStateChangedEventArgs> loadingStateChangeHandler = null; EventHandler<LoadingStateChangedEventArgs> loadingStateChangeHandler = null;
...@@ -543,7 +543,7 @@ namespace CefSharp ...@@ -543,7 +543,7 @@ namespace CefSharp
//Ensure our continuation is executed on the ThreadPool //Ensure our continuation is executed on the ThreadPool
//For the .Net Core implementation we could use //For the .Net Core implementation we could use
//TaskCreationOptions.RunContinuationsAsynchronously //TaskCreationOptions.RunContinuationsAsynchronously
tcs.TrySetResultAsync(new WaitForNavigationAsyncResponse(args.ErrorCode, -1)); tcs.TrySetResult(new WaitForNavigationAsyncResponse(args.ErrorCode, -1));
}; };
loadingStateChangeHandler = (sender, args) => loadingStateChangeHandler = (sender, args) =>
...@@ -574,7 +574,7 @@ namespace CefSharp ...@@ -574,7 +574,7 @@ namespace CefSharp
//Ensure our continuation is executed on the ThreadPool //Ensure our continuation is executed on the ThreadPool
//For the .Net Core implementation we could use //For the .Net Core implementation we could use
//TaskCreationOptions.RunContinuationsAsynchronously //TaskCreationOptions.RunContinuationsAsynchronously
tcs.TrySetResultAsync(new WaitForNavigationAsyncResponse(statusCode == -1 ? CefErrorCode.Failed : CefErrorCode.None, statusCode)); tcs.TrySetResult(new WaitForNavigationAsyncResponse(statusCode == -1 ? CefErrorCode.Failed : CefErrorCode.None, statusCode));
} }
}; };
......
...@@ -12,21 +12,21 @@ ...@@ -12,21 +12,21 @@
<tags>chrome browser</tags> <tags>chrome browser</tags>
<copyright>Copyright © The CefSharp Authors</copyright> <copyright>Copyright © The CefSharp Authors</copyright>
<dependencies> <dependencies>
<group targetFramework=".NETFramework4.5.2"> <group targetFramework=".NETFramework4.6.2">
<dependency id="cef.redist.x86" version="[$RedistVersion$]" /> <dependency id="cef.redist.x86" version="[$RedistVersion$]" />
<dependency id="cef.redist.x64" version="[$RedistVersion$]" /> <dependency id="cef.redist.x64" version="[$RedistVersion$]" />
</group> </group>
</dependencies> </dependencies>
</metadata> </metadata>
<files> <files>
<file src="..\CefSharp\bin\Release\CefSharp.dll" target="lib\net452"/> <file src="..\CefSharp\bin\Release\CefSharp.dll" target="lib\net462"/>
<file src="..\CefSharp\bin\Release\CefSharp.xml" target="lib\net452"/> <file src="..\CefSharp\bin\Release\CefSharp.xml" target="lib\net462"/>
<file src="..\CefSharp\bin\Release\CefSharp.pdb" target="lib\net452"/> <file src="..\CefSharp\bin\Release\CefSharp.pdb" target="lib\net462"/>
<file src="..\CefSharp.Core\bin\Release\CefSharp.Core.dll" target="lib\net452"/> <file src="..\CefSharp.Core\bin\Release\CefSharp.Core.dll" target="lib\net462"/>
<file src="..\CefSharp.Core\bin\Release\CefSharp.Core.xml" target="lib\net452"/> <file src="..\CefSharp.Core\bin\Release\CefSharp.Core.xml" target="lib\net462"/>
<file src="..\CefSharp.Core\bin\Release\CefSharp.Core.pdb" target="lib\net452"/> <file src="..\CefSharp.Core\bin\Release\CefSharp.Core.pdb" target="lib\net462"/>
<!-- Cannot put these inside lib\net452 etc, since there are both x86 and x64 versions which we must distinguish between. We <!-- Cannot put these inside lib\net462 etc, since there are both x86 and x64 versions which we must distinguish between. We
solve this using a .targets file instead to copy them based on PlatformTarget --> solve this using a .targets file instead to copy them based on PlatformTarget -->
<!-- Common CefSharp stuff (shared between both WPF, Offscreen and WinForms) --> <!-- Common CefSharp stuff (shared between both WPF, Offscreen and WinForms) -->
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
<CefSharpCommonBinaries32 Include="$(MSBuildThisFileDirectory)..\CefSharp\x86\*.*" /> <CefSharpCommonBinaries32 Include="$(MSBuildThisFileDirectory)..\CefSharp\x86\*.*" />
<CefSharpCommonBinaries64 Include="$(MSBuildThisFileDirectory)..\CefSharp\x64\*.*" /> <CefSharpCommonBinaries64 Include="$(MSBuildThisFileDirectory)..\CefSharp\x64\*.*" />
<CefSharpCommonBinariesAnyCPU Include="$(MSBuildThisFileDirectory)..\CefSharp\**\*.*" /> <CefSharpCommonBinariesAnyCPU Include="$(MSBuildThisFileDirectory)..\CefSharp\**\*.*" />
<CefSharpCommonManagedDlls Include="$(MSBuildThisFileDirectory)..\lib\net452\**\*.*" /> <CefSharpCommonManagedDlls Include="$(MSBuildThisFileDirectory)..\lib\net462\**\*.*" />
<!-- Just CefSharp.dlll --> <!-- Just CefSharp.dlll -->
<CefSharpCommonManagedDll Include="$(MSBuildThisFileDirectory)..\lib\net452\CefSharp.dll" /> <CefSharpCommonManagedDll Include="$(MSBuildThisFileDirectory)..\lib\net462\CefSharp.dll" />
<CefSharpCommonTransform32 Include="$(MSBuildThisFileDirectory)..\build\app.config.x86.transform"/> <CefSharpCommonTransform32 Include="$(MSBuildThisFileDirectory)..\build\app.config.x86.transform"/>
<CefSharpCommonTransform64 Include="$(MSBuildThisFileDirectory)..\build\app.config.x64.transform"/> <CefSharpCommonTransform64 Include="$(MSBuildThisFileDirectory)..\build\app.config.x64.transform"/>
......
...@@ -397,7 +397,7 @@ ...@@ -397,7 +397,7 @@
<Message Importance="high" Text="Copying CefSharp Common x86 files from $(MSBuildThisFileDirectory)..\CefSharp\x86 to $(CefRedist32TargetDir)" /> <Message Importance="high" Text="Copying CefSharp Common x86 files from $(MSBuildThisFileDirectory)..\CefSharp\x86 to $(CefRedist32TargetDir)" />
<Copy SourceFiles="@(_CefSharpCommonBinaries32)" DestinationFiles="@(_CefSharpCommonBinaries32->'$(CefRedist32TargetDir)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" /> <Copy SourceFiles="@(_CefSharpCommonBinaries32)" DestinationFiles="@(_CefSharpCommonBinaries32->'$(CefRedist32TargetDir)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
<Message Importance="high" Text="Copying CefSharp.dll from $(MSBuildThisFileDirectory)..\lib\net452\CefSharp.dll to $(CefRedist32TargetDir)" /> <Message Importance="high" Text="Copying CefSharp.dll from $(MSBuildThisFileDirectory)..\lib\net462\CefSharp.dll to $(CefRedist32TargetDir)" />
<Copy SourceFiles="@(_CefSharpCommonManagedDll)" DestinationFiles="@(_CefSharpCommonManagedDll->'$(CefRedist32TargetDir)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" /> <Copy SourceFiles="@(_CefSharpCommonManagedDll)" DestinationFiles="@(_CefSharpCommonManagedDll->'$(CefRedist32TargetDir)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target> </Target>
...@@ -408,7 +408,7 @@ ...@@ -408,7 +408,7 @@
<Message Importance="high" Text="Copying CefSharp Common x64 files from $(MSBuildThisFileDirectory)..\CefSharp\x64 to $(CefRedist64TargetDir)" /> <Message Importance="high" Text="Copying CefSharp Common x64 files from $(MSBuildThisFileDirectory)..\CefSharp\x64 to $(CefRedist64TargetDir)" />
<Copy SourceFiles="@(_CefSharpCommonBinaries64)" DestinationFiles="@(_CefSharpCommonBinaries64->'$(CefRedist64TargetDir)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" /> <Copy SourceFiles="@(_CefSharpCommonBinaries64)" DestinationFiles="@(_CefSharpCommonBinaries64->'$(CefRedist64TargetDir)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
<Message Importance="high" Text="Copying CefSharp.dll from $(MSBuildThisFileDirectory)..\lib\net452\CefSharp.dll to $(CefRedist64TargetDir)" /> <Message Importance="high" Text="Copying CefSharp.dll from $(MSBuildThisFileDirectory)..\lib\net462\CefSharp.dll to $(CefRedist64TargetDir)" />
<Copy SourceFiles="@(_CefSharpCommonManagedDll)" DestinationFiles="@(_CefSharpCommonManagedDll->'$(CefRedist64TargetDir)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" /> <Copy SourceFiles="@(_CefSharpCommonManagedDll)" DestinationFiles="@(_CefSharpCommonManagedDll->'$(CefRedist64TargetDir)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target> </Target>
...@@ -427,7 +427,7 @@ ...@@ -427,7 +427,7 @@
<CefRedist64TargetDir Condition="'$(_CefSharpPlatformTarget)' == 'AnyCPU'">$(CefRedist64TargetDir)x64\</CefRedist64TargetDir> <CefRedist64TargetDir Condition="'$(_CefSharpPlatformTarget)' == 'AnyCPU'">$(CefRedist64TargetDir)x64\</CefRedist64TargetDir>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<_CefSharpCommonManagedDll Include="$(MSBuildThisFileDirectory)..\lib\net452\CefSharp.dll" /> <_CefSharpCommonManagedDll Include="$(MSBuildThisFileDirectory)..\lib\net462\CefSharp.dll" />
<_CefSharpCommonBinaries32 Include="$(MSBuildThisFileDirectory)..\CefSharp\x86\*.*" /> <_CefSharpCommonBinaries32 Include="$(MSBuildThisFileDirectory)..\CefSharp\x86\*.*" />
<_CefSharpCommonBinaries64 Include="$(MSBuildThisFileDirectory)..\CefSharp\x64\*.*" /> <_CefSharpCommonBinaries64 Include="$(MSBuildThisFileDirectory)..\CefSharp\x64\*.*" />
</ItemGroup> </ItemGroup>
......
...@@ -12,10 +12,7 @@ ...@@ -12,10 +12,7 @@
<tags>osr chrome browser chromium-embedded cefsharp</tags> <tags>osr chrome browser chromium-embedded cefsharp</tags>
<copyright>Copyright © The CefSharp Authors</copyright> <copyright>Copyright © The CefSharp Authors</copyright>
<dependencies> <dependencies>
<group targetFramework=".NETFramework4.5.2"> <group targetFramework=".NETFramework4.6.2">
<dependency id="CefSharp.Common" version="[$version$]" />
</group>
<group targetFramework=".NETFramework4.6.2">
<dependency id="CefSharp.Common" version="[$version$]" /> <dependency id="CefSharp.Common" version="[$version$]" />
</group> </group>
</dependencies> </dependencies>
...@@ -27,11 +24,7 @@ ...@@ -27,11 +24,7 @@
</releaseNotes> </releaseNotes>
</metadata> </metadata>
<files> <files>
<file src="..\CefSharp.OffScreen\bin\Release\net452\CefSharp.OffScreen.dll" target="lib\net452" /> <file src="..\CefSharp.OffScreen\bin\Release\net462\CefSharp.OffScreen.dll" target="lib\net462" />
<file src="..\CefSharp.OffScreen\bin\Release\net452\CefSharp.OffScreen.xml" target="lib\net452" />
<file src="..\CefSharp.OffScreen\bin\Release\net452\CefSharp.OffScreen.pdb" target="lib\net452" />
<file src="..\CefSharp.OffScreen\bin\Release\net462\CefSharp.OffScreen.dll" target="lib\net462" />
<file src="..\CefSharp.OffScreen\bin\Release\net462\CefSharp.OffScreen.xml" target="lib\net462" /> <file src="..\CefSharp.OffScreen\bin\Release\net462\CefSharp.OffScreen.xml" target="lib\net462" />
<file src="..\CefSharp.OffScreen\bin\Release\net462\CefSharp.OffScreen.pdb" target="lib\net462" /> <file src="..\CefSharp.OffScreen\bin\Release\net462\CefSharp.OffScreen.pdb" target="lib\net462" />
......
...@@ -12,10 +12,7 @@ ...@@ -12,10 +12,7 @@
<tags>winforms chrome browser chromium-embedded cefsharp</tags> <tags>winforms chrome browser chromium-embedded cefsharp</tags>
<copyright>Copyright © The CefSharp Authors</copyright> <copyright>Copyright © The CefSharp Authors</copyright>
<dependencies> <dependencies>
<group targetFramework=".NETFramework4.5.2"> <group targetFramework=".NETFramework4.6.2">
<dependency id="CefSharp.Common" version="[$version$]" />
</group>
<group targetFramework=".NETFramework4.6.2">
<dependency id="CefSharp.Common" version="[$version$]" /> <dependency id="CefSharp.Common" version="[$version$]" />
</group> </group>
</dependencies> </dependencies>
...@@ -27,11 +24,7 @@ ...@@ -27,11 +24,7 @@
</releaseNotes> </releaseNotes>
</metadata> </metadata>
<files> <files>
<file src="..\CefSharp.WinForms\bin\Release\net452\CefSharp.WinForms.dll" target="lib\net452" /> <file src="..\CefSharp.WinForms\bin\Release\net462\CefSharp.WinForms.dll" target="lib\net462" />
<file src="..\CefSharp.WinForms\bin\Release\net452\CefSharp.WinForms.xml" target="lib\net452" />
<file src="..\CefSharp.WinForms\bin\Release\net452\CefSharp.WinForms.pdb" target="lib\net452" />
<file src="..\CefSharp.WinForms\bin\Release\net462\CefSharp.WinForms.dll" target="lib\net462" />
<file src="..\CefSharp.WinForms\bin\Release\net462\CefSharp.WinForms.xml" target="lib\net462" /> <file src="..\CefSharp.WinForms\bin\Release\net462\CefSharp.WinForms.xml" target="lib\net462" />
<file src="..\CefSharp.WinForms\bin\Release\net462\CefSharp.WinForms.pdb" target="lib\net462" /> <file src="..\CefSharp.WinForms\bin\Release\net462\CefSharp.WinForms.pdb" target="lib\net462" />
......
...@@ -12,10 +12,7 @@ ...@@ -12,10 +12,7 @@
<tags>wpf chrome browser chromium-embedded cefsharp</tags> <tags>wpf chrome browser chromium-embedded cefsharp</tags>
<copyright>Copyright © The CefSharp Authors</copyright> <copyright>Copyright © The CefSharp Authors</copyright>
<dependencies> <dependencies>
<group targetFramework=".NETFramework4.5.2"> <group targetFramework=".NETFramework4.6.2">
<dependency id="CefSharp.Common" version="[$version$]" />
</group>
<group targetFramework=".NETFramework4.6.2">
<dependency id="CefSharp.Common" version="[$version$]" /> <dependency id="CefSharp.Common" version="[$version$]" />
</group> </group>
</dependencies> </dependencies>
...@@ -27,11 +24,7 @@ ...@@ -27,11 +24,7 @@
</releaseNotes> </releaseNotes>
</metadata> </metadata>
<files> <files>
<file src="..\CefSharp.Wpf\bin\Release\net452\CefSharp.Wpf.dll" target="lib\net452" /> <file src="..\CefSharp.Wpf\bin\Release\net462\CefSharp.Wpf.dll" target="lib\net462" />
<file src="..\CefSharp.Wpf\bin\Release\net452\CefSharp.Wpf.xml" target="lib\net452" />
<file src="..\CefSharp.Wpf\bin\Release\net452\CefSharp.Wpf.pdb" target="lib\net452" />
<file src="..\CefSharp.Wpf\bin\Release\net462\CefSharp.Wpf.dll" target="lib\net462" />
<file src="..\CefSharp.Wpf\bin\Release\net462\CefSharp.Wpf.xml" target="lib\net462" /> <file src="..\CefSharp.Wpf\bin\Release\net462\CefSharp.Wpf.xml" target="lib\net462" />
<file src="..\CefSharp.Wpf\bin\Release\net462\CefSharp.Wpf.pdb" target="lib\net462" /> <file src="..\CefSharp.Wpf\bin\Release\net462\CefSharp.Wpf.pdb" target="lib\net462" />
......
...@@ -18,11 +18,11 @@ Deployment: ...@@ -18,11 +18,11 @@ Deployment:
What's New: What's New:
See https://github.com/cefsharp/CefSharp/releases See https://github.com/cefsharp/CefSharp/releases
IMPORTANT NOTE - Visual C++ 2019 or greater is required IMPORTANT NOTE - Visual C++ 2019 or greater is required
IMPORTANT NOTE - .NET Framework 4.5.2 or greater is required. IMPORTANT NOTE - .NET Framework 4.6.2 or greater is required.
IMPORTANT NOTE - Chromium support for Windows 7/8/8.1 ends with version 109, starting with version 110 a minimum of Windows 10 is required. IMPORTANT NOTE - Chromium support for Windows 7/8/8.1 ends with version 109, starting with version 110 a minimum of Windows 10 is required.
Basic Troubleshooting: Basic Troubleshooting:
- Minimum of .Net 4.5.2 - Minimum of .Net 4.6.2
- Minimum of `Visual C++ 2019 Redist` is installed (either `x86` or `x64` depending on your application). - Minimum of `Visual C++ 2019 Redist` is installed (either `x86` or `x64` depending on your application).
- Please ensure your binaries directory contains these required dependencies: - Please ensure your binaries directory contains these required dependencies:
* libcef.dll (Chromium Embedded Framework Core library) * libcef.dll (Chromium Embedded Framework Core library)
......
...@@ -88,7 +88,7 @@ If you're new to `CefSharp` and are downloading the source to check it out, plea ...@@ -88,7 +88,7 @@ If you're new to `CefSharp` and are downloading the source to check it out, plea
| Branch | CEF Version | VC++ Version | .Net Version | Status | | Branch | CEF Version | VC++ Version | .Net Version | Status |
|-----------------------------------------------------------------------|------|-------|---------|-----------------| |-----------------------------------------------------------------------|------|-------|---------|-----------------|
| [master](https://github.com/cefsharp/CefSharp/) | 5615 | 2019* | 4.5.2** | Development | | [master](https://github.com/cefsharp/CefSharp/) | 5615 | 2019* | 4.6.2** | Development |
| [cefsharp/113](https://github.com/cefsharp/CefSharp/tree/cefsharp/113)| 5615 | 2019* | 4.5.2** | **Release** | | [cefsharp/113](https://github.com/cefsharp/CefSharp/tree/cefsharp/113)| 5615 | 2019* | 4.5.2** | **Release** |
| [cefsharp/112](https://github.com/cefsharp/CefSharp/tree/cefsharp/112)| 5615 | 2019* | 4.5.2** | Unsupported | | [cefsharp/112](https://github.com/cefsharp/CefSharp/tree/cefsharp/112)| 5615 | 2019* | 4.5.2** | Unsupported |
| [cefsharp/111](https://github.com/cefsharp/CefSharp/tree/cefsharp/111)| 5563 | 2019* | 4.5.2** | Unsupported | | [cefsharp/111](https://github.com/cefsharp/CefSharp/tree/cefsharp/111)| 5563 | 2019* | 4.5.2** | Unsupported |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册