Appium c# -How to handle random error pop ups in the UI screen and continue

I am using Appium with Windows App driver to automate my Desktop application. I am using C#.
When I start testing my app, I sometime encounter random error pop up , which can be ignored and continued with my execution, by clicking on OK in the pop up. My question is how to handle it when this pop up randomly coming up. I thought of creating a method of checking if the pop up is present and then click on OK to close it but I have to call this method before every step , since its random. Is there a better way to do this?

How about disabling those random popup. Add an option to disable random popups which can be ignored anyway.

Sorry I didnt get it. What to you mean by disabling the pop up.Do you mean disabling through the automation code ? I am not sure how to do that. There is no other way of disabling or predicting when these pop ups would come. Basically these are run time error pop ups from our WPF application.