Hello,
I have the following code in a class of mine. The purpose of this class is to get the balance from a web server. Just in case something goes wrong with getting the balance. I will handle a exception. However, all this is easy to do. But I am left wondering what do I return in my catch statement.
Most of the examples I looked at just write to the console using:
Console.WriteLine(ex.Message);
That is all very well. But in a real application what do most developers do?
My function at the moment returns void. And I am just wondering what else I would return if the webclient is busy?
Many thanks for any advice,
Code:'Download only when the webclient is not busy. If (Not wc.IsBusy) Then ' Sleep for 1/2 second to give the server time to update the balance. System.Threading.Thread.Sleep(500) Try ' Download the current balance. wc.DownloadStringAsync(New Uri(strURL)) Catch ex As WebException Console.Write("GetBalance(): " & ex.Message) End Try Else Console.Write("Busy please try again") End If


Reply With Quote
