network aware windows application

  • Thread starter Thread starter thomasamillergoogle
  • Start date Start date
T

thomasamillergoogle

Hello,
I am working on a windows application that has to be network aware.
What is the correct way to make it network aware?

On startup the program must call a web service to retrieve data. Right
now I start a Timer that calls an asynchronous web service called
CheckConnection() every five seconds. When a "good" callback is
received then I stop the timers and load the data from the web service.

Is there a better way to do it??
 
Hi,
If you want to check a local network adress a simple tcp/ip ping would be
suffient.
If you want to check access to an internet location, you may consider using
the HttpWebRequest class. Something like:

string url = "http://www.acme.com";
HttpWebRequest req = HttpWebRequest.Create(url) as HttpWebRequest;
HttpWebResponse res = req.GetResponse() as HttpWebResponse;

GetResponse() throws an exception if the specified url network address is
not accessible. Otherwise connection is fine.
 
httpwebrequest nomally works fine, but at system startup it is not
reliable. I was using hhttpwebrequest but found that calling a simple
'hello world' web service is the only reliable way to do it at system
startup.

I am more concerned with knowing if my timer way of doing it is
correct. Or does anybody have any example code of how to have a thread
that repeatedly consumes an asynch webservice and waits for the
callback? Would this be a better way to do it then the timer?
 
Back
Top