Skip to content

Commit

Permalink
Added await in async field initialization. Fixes #1701
Browse files Browse the repository at this point in the history
  • Loading branch information
tidyui committed Oct 19, 2021
1 parent 4692832 commit f5f7c46
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ examples/CoreWeb/assets/lib
# Runtime test files
[Uu]ploads
*.db
*.db-shm
*.db-wal

templates/**/wwwroot/uploads
templates/**/*.db
Expand Down
9 changes: 4 additions & 5 deletions core/Piranha/Runtime/AppMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public sealed class AppMethod
/// <param name="instance">The object instance</param>
/// <param name="scope">The current service scope</param>
/// <returns>An async taks</returns>
public Task InvokeAsync(object instance, IServiceScope scope)
public async Task InvokeAsync(object instance, IServiceScope scope)
{
var param = new List<object>();
foreach (var type in ParameterTypes)
Expand All @@ -49,13 +49,12 @@ public Task InvokeAsync(object instance, IServiceScope scope)

if (IsAsync)
{
return (Task)Method.Invoke(instance, param.ToArray());
await ((Task)Method.Invoke(instance, param.ToArray()))
.ConfigureAwait(false);
}
else
{
return Task.Run(() => {
Method.Invoke(instance, param.ToArray());
});
Method.Invoke(instance, param.ToArray());
}
}
}
Expand Down

0 comments on commit f5f7c46

Please sign in to comment.