Make variable wait function to be generated

Asked

Viewed 86 times

0

I have the following code:

XmlParaApi = xml;

that passes a string variable (xml) to a string global variable (Xmlparaapi). Until then all this code is in an Api, the Gora my problem is with the code below:

 string XmlApi = XmlApi.XmlParaApi;

The problem occurs because I make two functions occur simultaneously, only I need the second code to wait for the variable (Xmlparaapi) to be ready to be used, I’ve seen that there is a way to do by "Wait", but I haven’t been able to do, someone can help?

1 answer

0

where you must wait, you can wear a while...

ex:

    While (String.IsNullOrEmpty(XmlApi))
    {
        System.Threading.Thread.Sleep(500);
    }

Obs. I am considering that the variable will be populated in another thread, and that it will always be populated. Otherwise, put some trigger to exit while for example, after 100 attempts, so that the application is not locked in this command.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.