File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
src/Yapoml.Framework/Logging Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -23,5 +23,5 @@ public interface ILogScope : IDisposable
23
23
24
24
void Execute ( Action action ) ;
25
25
26
- void Execute ( Func < Task > func ) ;
26
+ TResult Execute < TResult > ( Func < TResult > func ) ;
27
27
}
Original file line number Diff line number Diff line change @@ -53,17 +53,28 @@ public void Execute(Action action)
53
53
}
54
54
}
55
55
56
- public void Execute ( Func < Task > func )
56
+ public TResult Execute < TResult > ( Func < TResult > action )
57
57
{
58
+ TResult result ;
59
+
58
60
try
59
61
{
60
- func ( ) . GetAwaiter ( ) . GetResult ( ) ;
62
+ result = action ( ) ;
63
+
64
+ var task = result as Task ;
65
+
66
+ if ( task is not null )
67
+ {
68
+ task . GetAwaiter ( ) . GetResult ( ) ;
69
+ }
61
70
}
62
71
catch ( Exception ex )
63
72
{
64
73
Error = ex ;
65
74
throw ;
66
75
}
76
+
77
+ return result ;
67
78
}
68
79
69
80
public void Dispose ( )
You can’t perform that action at this time.
0 commit comments