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
// HandleButtonTapped continues execution here while `ExampleAsyncMethod()` is running on a different thread
130
+
// ...
131
+
}
132
+
133
+
asyncTaskExampleAsyncMethod()
134
+
{
135
+
awaitTask.Delay(1000);
136
+
}
137
+
```
138
+
139
+
#### Advanced Usage
140
+
119
141
```csharp
142
+
voidInitializeSafeFireAndForget()
143
+
{
144
+
// Initialize SafeFireAndForget
145
+
// Only use `shouldAlwaysRethrowException: true` when you want `.SafeFireAndForget()` to always rethrow every exception. This is not recommended, because there is no way to catch an Exception rethrown by `SafeFireAndForget()`; `shouldAlwaysRethrowException: true` should **not** be used in Production/Release builds.
// onException: If a WebException is thrown, print its StatusCode to the Console. **Note**: If a non-WebException is thrown, it will not be handled by `onException`
157
+
158
+
// Because we set `SetDefaultExceptionHandling` in `void InitializeSafeFireAndForget()`, the entire exception will also be printed to the Console
An event implementation that enables the [garbage collector to collect an object without needing to unsubscribe event handlers](http://paulstovell.com/blog/weakevents), inspired by [Xamarin.Forms.WeakEventManager](https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Core/WeakEventManager.cs):
178
+
An event implementation that enables the [garbage collector to collect an object without needing to unsubscribe event handlers](http://paulstovell.com/blog/weakevents).
179
+
180
+
Inspired by [Xamarin.Forms.WeakEventManager](https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Core/WeakEventManager.cs).
An event implementation that enables the [garbage collector to collect an object without needing to unsubscribe event handlers](http://paulstovell.com/blog/weakevents), inspired by [Xamarin.Forms.WeakEventManager](https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Core/WeakEventManager.cs).
- Added support for `event Action` and `event Action<T>`
22
+
- Added support for `.SafeFireAndForget<TException>()`
23
+
- Added `SafeFireAndForgetExtensions.SetDefaultExceptionHandling(Action<Exception> onException)` to set a default action for every call to `SafeFireAndForget`
24
+
- Added `SafeFireAndForgetExtensions.Initialize(bool shouldAlwaysRethrowException = false)`. When set to `true` will rethrow every exception caught by `SafeFireAndForget`. Warning: `SafeFireAndForgetExtensions.Initialize(true)` is only recommended for DEBUG environments.
25
+
- Added support for `Exception innerException` to `InvalidCommandParameterException`
26
+
- Breaking Change: Changed default value to `continueOnCapturedContext = false`. This improves performance by not requiring a context switch when `.SafeFireAndForget()` and `IAsyncCommand` have completed.
0 commit comments