Jump to content

Asynchronous APIs and Background Threads

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
danfloun

danfloun

    Newbie

  • Members
  • Pip
  • 3 posts
Hi,

When I run WebRequest or HttpWebRequest to check for a response from my server, all works fine.

To initiate the default timeout built into WebRequest, I disabled the internet connection in my router. During the attempt for a request the UI freezes, which I know is normal.

So, I'm puzzled as to whether I use an Asynchronous HttpWebRequest, or simply initiate the WebRequest in a background thread.

My understanding is that it is basically the same thing, is this wrong!

My requirements;

When I click a button, it does various procedures to check for an internet connection. Upon getting a result it displays this in a textbox on the UI.
So if I run a WebRequest in the background, I don't want the UI to freeze and I want a callback from the background thread or Async API to update the textbox with the results.

My question;
What is the difference between using an Asynchronous HttpWebRequest and running a WebRequest in a background thread?

Which should I use?


Thanks
Danny

#2
thanasis2028

thanasis2028

    Learning Programmer

  • Members
  • PipPipPip
  • 31 posts
I believe the Asynchronous HttpWebRequest might be optimized by Microsoft and it would be better than running a WebRequest in a background thread. Anyway, it won't have a big difference.
My software company:Porosis Software
Games: Terrantula
Apps: Mathanasis, ColorGrabber (New!)