Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7747365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:30:38+00:00 2026-06-01T10:30:38+00:00

Hola check this code. var watch = new Stopwatch(); watch.Start(); var request = HttpWebRequest.Create(new

  • 0

Hola check this code.

     var watch = new Stopwatch();
     watch.Start();
     var request = HttpWebRequest.Create(new Uri("http://localhost:59449/stwebapi/chat?userId=john")) as HttpWebRequest;
     Console.WriteLine(watch.Elapsed);

     Thread.Sleep(5000);

     watch.Restart();
     var response = request.GetResponse();
     Console.WriteLine(watch.Elapsed);

I sent web request, waited for a long time and then got the response. Still response took longer to execute. The result I got was

00:00:00.1142339
00:00:03.1365544

Why response took me 3 seconds?
Same response lag is there with asynchronous response.

I want GetResponse function to be executed immediately. How can I achieve that?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T10:30:39+00:00Added an answer on June 1, 2026 at 10:30 am

    I strongly suspect that until you call GetResponse, the request isn’t even sent… so your Thread.Sleep is basically doing you no good at all.

    Why don’t you just call GetResponse immediately? If it takes 3 seconds, then presumably that’s how long the web server took to answer your request…

    (As an aside, you should be using a using statement to make sure you dispose of the WebResponse; otherwise you’ll end up with requests timing out as the connection pool waits for a connection to become available.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: (function ($) { $(document).ready(function() { test(hola,caracola); }); function test(somevar1, somevar2)
Hi I'm creating a new audio tag element in Javascript this is the code:
im trying to create a script that opens a file and replace every 'hola'
after install Express.js, I wrote this on node: var express = require('express'), app =express.createServer();
I'm writing C++ code on a mac. Why do I get this error when
Here is my code- Logger log = Logger.getLogger(myApp); log.info(hola); it displays output as- Mar
I want to match a String which looks like this: [lang_de]Hallo![/lang_de][lang_en]Hello![/lang_en]HeyHo[lang_es]Hola![/lang_es] I want the
Please see the code below <html xmlns=http://www.w3.org/1999/xhtml> <head> <title>Test</title> </head> <body> <div> ¿Hola cómo
i dont know what is the name of this line of code.. and i
I have a code base that can be customized for different customers. This is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.