You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class Test
{
[Fact]
public async Task AsyncLambdaDoesntHangInTryBlock()
{
Expression<Func<Task<string>>> exprThrowException = () => ThrowException();
Expression<Func<Task<string>>> exprReprocess = () => Reprocess();
var asyncTryCatchExpression = AsyncLambda<Func<Task<string>>>(
(lambdaContext, result) =>
{
Try(() =>
{
Assign(result, Expression.Invoke(exprThrowException).Await());
Return(result);
})
.Catch<Exception>(() =>
{
Assign(result, Expression.Invoke(exprReprocess).Await());
Return(result);
})
.End();
});
var asyncTryCatchFunc = asyncTryCatchExpression.Compile();
var asyncTryCatchTask = asyncTryCatchFunc();
var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(5));
await await Task.WhenAny(asyncTryCatchTask, Task.Delay(-1, cancellationTokenSource.Token));
}
private static async Task<string> ThrowException()
{
await Task.Delay(TimeSpan.FromSeconds(1));
throw new Exception();
}
private static Task<string> Reprocess()
{
return Task.FromResult(string.Empty);
}
}
The text was updated successfully, but these errors were encountered:
ycherkes
changed the title
DotNext.Metaprogramming Regression: worked in v 2.12.2, hangs in higher versions.
DotNext.Metaprogramming. Regression: worked in v 2.12.2, hangs in higher versions.
Jun 4, 2021
The text was updated successfully, but these errors were encountered: