Function can only be called in the main thread, why?

In this code below I am calling the function displayMyAlertMessage() twice. the first I am calling works perfect, but the second one gives me an error saying that the function may only be called from the main thread. How can I do this in my situation?

You must always update UI elements from the main queue, sometimes works when you don't but most the time you have weird behaviours in your app, you luck that the compiler is warning you, sometimes take days to find mistakes like that when things just don't work