Skip to content

Commit 8245086

Browse files
Update README.md
1 parent 1c6e305 commit 8245086

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,16 @@ Extensions for `System.Threading.Tasks.Task`, inspired by [John Thiriet](https:/
3939
An extension method to safely fire-and-forget a `Task`:
4040
- `SafeFireAndForget`
4141

42+
```csharp
43+
public static async void SafeFireAndForget(this System.Threading.Tasks.Task task, bool continueOnCapturedContext = true, System.Action<System.Exception> onException = null)
44+
```
45+
4246
```csharp
4347
void HandleButtonTapped(object sender, EventArgs e)
4448
{
4549
// Allows the async Task method to safely run on a different thread while not awaiting its completion
46-
ExampleAsyncMethod().SafeFireAndForget();
50+
// If an exception is thrown, Console.WriteLine
51+
ExampleAsyncMethod().SafeFireAndForget(onException: ex => Console.WriteLine(ex.Message));
4752

4853
// HandleButtonTapped continues execution here while `ExampleAsyncMethod()` is running on a different thread
4954
// ...
@@ -62,6 +67,22 @@ Allows for `Task` to safely be used asynchronously with `ICommand`:
6267
- `AsyncCommand : IAsyncCommand`
6368
- `IAsyncCommand : ICommand`
6469

70+
71+
```csharp
72+
public AsyncCommand(Func<T, Task> execute,
73+
Func<object, bool> canExecute = null,
74+
Action<Exception> onException = null,
75+
bool continueOnCapturedContext = true)
76+
```
77+
78+
```csharp
79+
public AsyncCommand(Func<Task> execute,
80+
Func<object, bool> canExecute = null,
81+
Action<Exception> onException = null,
82+
bool continueOnCapturedContext = true)
83+
```
84+
85+
6586
```csharp
6687
public class ExampleClass
6788
{

0 commit comments

Comments
 (0)