markus / ConvertService / ServiceBase / Markus.Mvvm.ToolKit / TaskUtilities.cs @ 6b24246c
이력 | 보기 | 이력해설 | 다운로드 (617 Bytes)
1 | 45f9a2ad | taeseongkim | using System; |
---|---|---|---|
2 | using System.Threading.Tasks; |
||
3 | |||
4 | namespace Markus.Mvvm.ToolKit |
||
5 | { |
||
6 | public static class TaskUtilities |
||
7 | { |
||
8 | #pragma warning disable RECS0165 // Asynchronous methods should return a Task instead of void |
||
9 | public static async void FireAndForgetSafeAsync(this Task task, IErrorHandler handler = null) |
||
10 | #pragma warning restore RECS0165 // Asynchronous methods should return a Task instead of void |
||
11 | { |
||
12 | try |
||
13 | { |
||
14 | await task; |
||
15 | } |
||
16 | catch (Exception ex) |
||
17 | { |
||
18 | handler?.HandleError(ex); |
||
19 | } |
||
20 | } |
||
21 | } |
||
22 | } |