Search code examples
xamarinxamarin.formscustom-renderer

How to run async methods inside OnElementChanged method in a custom renderer


I need to run an async method in a custom renderer inside the OnElementChanged method; however, this method does not have an async signature. What's the recommended way to do async here? Is this method simply an event handler and can we modify the signature to async void OnElementChanged?


Solution

  • From VisualElementRenderer.cs and IVisualElementRenderer.cs

    OnElementChanged is an EventHandler so you can modify it signature with async like any other EventHandler Should I avoid 'async void' event handlers?