'ContinueWith' 可以用这些参数调用
'ContinueWith' can be called with these arguments
使用此处发布的 OAuthDesktopApp 示例:https://github.com/googlesamples/oauth-apps-for-windows,并转换为 vb.net,有一行代码显示为:
Dim responseTask As Task = responseOutput.WriteAsync(buffer, 0, buffer.Length).ContinueWith(Sub(task)
responseOutput.Close()
http.Stop()
Console.WriteLine("HTTP server stopped.")
End Sub)
当 运行 使用 dot net 框架版本 4.6.1 时,它在 WPF 应用程序中运行良好。但是,Windows Forms 应用程序中使用相同的点网框架版本的相同代码会导致在 运行 时间抛出以下异常:
Failed at ( ResolveOverloadedCall )
Overload resolution failed because no Public 'ContinueWith' can be called with these arguments:
'Public Function ContinueWith(continuationAction As System.Action`1[[System.Threading.Tasks.Task(Of Task(Of VoidTaskResult))) As System.Threading.Tasks.Task':
Argument matching parameter 'continuationAction' cannot convert from 'VB$AnonymousDelegate_0(Of Object)' to 'Action(Of Task(Of VoidTaskResult))'.
'Public Function ContinueWith(Of TNewResult)(continuationFunction As Func(Of Task(Of VoidTaskResult),TNewResult)) As Task(Of TNewResult)':
Type argument inference fails for argument matching parameter 'continuationFunction'.
'Public Function ContinueWith(Of TResult)(continuationFunction As Func(Of Task,TResult)) As Task(Of TResult)':
Type argument inference fails for argument matching parameter 'continuationFunction'.
'Public Function ContinueWith(continuationAction As System.Action(Of Task)) As System.Threading.Tasks.Task':
Argument matching parameter 'continuationAction' cannot convert from 'VB$AnonymousDelegate_0(Of Object)' to 'Action(Of Task)'.
我试过更改 dot net 框架的版本,并在 Whosebug 中搜索线索 - 但没有成功。
示例中的原始c代码供参考:
Task responseTask = responseOutput.WriteAsync(buffer, 0, buffer.Length).ContinueWith((task) =>
{
responseOutput.Close();
http.Stop();
Console.WriteLine("HTTP server stopped.");
});
如有任何见解,我们将不胜感激。
来自评论
Dim response = Await responseOutput.WriteAsync(buffer, 0, buffer.Length)
(并添加错误处理)
使用此处发布的 OAuthDesktopApp 示例:https://github.com/googlesamples/oauth-apps-for-windows,并转换为 vb.net,有一行代码显示为:
Dim responseTask As Task = responseOutput.WriteAsync(buffer, 0, buffer.Length).ContinueWith(Sub(task)
responseOutput.Close()
http.Stop()
Console.WriteLine("HTTP server stopped.")
End Sub)
当 运行 使用 dot net 框架版本 4.6.1 时,它在 WPF 应用程序中运行良好。但是,Windows Forms 应用程序中使用相同的点网框架版本的相同代码会导致在 运行 时间抛出以下异常:
Failed at ( ResolveOverloadedCall ) Overload resolution failed because no Public 'ContinueWith' can be called with these arguments: 'Public Function ContinueWith(continuationAction As System.Action`1[[System.Threading.Tasks.Task(Of Task(Of VoidTaskResult))) As System.Threading.Tasks.Task': Argument matching parameter 'continuationAction' cannot convert from 'VB$AnonymousDelegate_0(Of Object)' to 'Action(Of Task(Of VoidTaskResult))'. 'Public Function ContinueWith(Of TNewResult)(continuationFunction As Func(Of Task(Of VoidTaskResult),TNewResult)) As Task(Of TNewResult)': Type argument inference fails for argument matching parameter 'continuationFunction'.
'Public Function ContinueWith(Of TResult)(continuationFunction As Func(Of Task,TResult)) As Task(Of TResult)': Type argument inference fails for argument matching parameter 'continuationFunction'.
'Public Function ContinueWith(continuationAction As System.Action(Of Task)) As System.Threading.Tasks.Task': Argument matching parameter 'continuationAction' cannot convert from 'VB$AnonymousDelegate_0(Of Object)' to 'Action(Of Task)'.
我试过更改 dot net 框架的版本,并在 Whosebug 中搜索线索 - 但没有成功。
示例中的原始c代码供参考:
Task responseTask = responseOutput.WriteAsync(buffer, 0, buffer.Length).ContinueWith((task) =>
{
responseOutput.Close();
http.Stop();
Console.WriteLine("HTTP server stopped.");
});
如有任何见解,我们将不胜感激。
来自评论
Dim response = Await responseOutput.WriteAsync(buffer, 0, buffer.Length)
(并添加错误处理)