diff --git a/README.md b/README.md index 5d44dba..0296336 100644 --- a/README.md +++ b/README.md @@ -149,12 +149,16 @@ void InitializeSafeFireAndForget() SafeFireAndForgetExtensions.SetDefaultExceptionHandling(ex => Console.WriteLine(ex)); } +void UninitializeSafeFireAndForget() +{ + // Remove default exception handling + SafeFireAndForgetExtensions.RemoveDefaultExceptionHandling() +} + void HandleButtonTapped(object sender, EventArgs e) { // Allows the async Task method to safely run on a different thread while not awaiting its completion - // 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` - // Because we set `SetDefaultExceptionHandling` in `void InitializeSafeFireAndForget()`, the entire exception will also be printed to the Console ExampleAsyncMethod().SafeFireAndForget(onException: ex => { @@ -163,7 +167,6 @@ void HandleButtonTapped(object sender, EventArgs e) }); // HandleButtonTapped continues execution here while `ExampleAsyncMethod()` is running on a different thread - // ... } async Task ExampleAsyncMethod() @@ -190,7 +193,7 @@ public event EventHandler CanExecuteChanged remove => _weakEventManager.RemoveEventHandler(value); } -public void OnCanExecuteChanged() => _canExecuteChangedEventManager.HandleEvent(this, EventArgs.Empty, nameof(CanExecuteChanged)); +void OnCanExecuteChanged() => _canExecuteChangedEventManager.HandleEvent(this, EventArgs.Empty, nameof(CanExecuteChanged)); ``` #### Using `Delegate` @@ -204,7 +207,7 @@ public event PropertyChangedEventHandler PropertyChanged remove => _propertyChangedEventManager.RemoveEventHandler(value); } -public void OnPropertyChanged([CallerMemberName]string propertyName = "") => _propertyChangedEventManager.HandleEvent(this, new PropertyChangedEventArgs(propertyName), nameof(PropertyChanged)); +void OnPropertyChanged([CallerMemberName]string propertyName = "") => _propertyChangedEventManager.HandleEvent(this, new PropertyChangedEventArgs(propertyName), nameof(PropertyChanged)); ``` #### Using `Action` @@ -218,7 +221,7 @@ public event Action ActionEvent remove => _weakActionEventManager.RemoveEventHandler(value); } -public void OnActionEvent(string message) => _weakActionEventManager.HandleEvent(message, nameof(ActionEvent)); +void OnActionEvent(string message) => _weakActionEventManager.HandleEvent(message, nameof(ActionEvent)); ``` ### `WeakEventManager` @@ -235,7 +238,7 @@ public event EventHandler ErrorOcurred remove => _errorOcurredEventManager.RemoveEventHandler(value); } -public void OnErrorOcurred(string message) => _errorOcurredEventManager.HandleEvent(this, message, nameof(ErrorOcurred)); +void OnErrorOcurred(string message) => _errorOcurredEventManager.HandleEvent(this, message, nameof(ErrorOcurred)); ``` #### Using `Action` @@ -249,7 +252,7 @@ public event Action ActionEvent remove => _weakActionEventManager.RemoveEventHandler(value); } -public void OnActionEvent(string message) => _weakActionEventManager.HandleEvent(message, nameof(ActionEvent)); +void OnActionEvent(string message) => _weakActionEventManager.HandleEvent(message, nameof(ActionEvent)); ``` ## AsyncAwaitBestPractices.MVVM