C#C
C#3y ago
5 replies
Indeed

Wait for async function in synchronous context for X time until cancel

Hi!
How can i wait X time for this function to finish or otherwise throw/cancel/return something
This function comes from an outside library

    public bool ValidateAddress(Address address) {
        try {
            //wait for x or throw
            weatherApi.GetCurrentWeatherAsync(cityName: address.CityName);
            return true;
        }
        catch {
            return false;
        }
    }


Only things I see are with usage of await but i need this method to be synchronous
Was this page helpful?