Need some advice.

I am writing a translator program under WinPhone. During a request to the translator api, I catch an internet connection timeout error. So I think it can turn on each time the "Translation" button is clicked, in order not to make the user wait until the error is caught, but to immediately indicate that the network is unavailable:

if (!DeviceNetworkInformation.IsNetworkAvailable) { // уведомляем что сеть недоступна } else { // выполняем код перевода } 

Now I think, but whether it will not take away too much time and memory for such a test? I will be glad to any comments and advice.

Thank!

  • This check takes some milliseconds in time. What exactly is the question? - Olter
  • In addition, it does not check the availability of access to the Internet, and the presence of a connection to the telephone network, which is not the same thing. - andreycha
  • @andreycha, is it? From infa? - Olter
  • hashcode.ru/users/106/andreycha This check looks to see if it is possible to connect to the network in any way (cellular network, wifi or PC). hashcode.ru/users/5357/olter The question is whether it makes sense to put this check or just catch the network errors try catch? - dad495

1 answer 1

@ dad495 , here, in general, this is the case:

Ask yourself the question: how big is the chance that your application will not have a connection to the network when you click on the "translation" button?

I would do such a check once — when the application is started (and when I click on the button, the usual try-catch). But in principle, this check does not add a special load (I speak from personal experience, let them correct me if I'm wrong), i.e. The question is, in general, "How paranoid is the programmer who writes this?"

I hope I clearly explained.

  • Thank! Just trying to take everything into account. - dad495