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 6721599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:20:55+00:00 2026-05-26T09:20:55+00:00

I have some code from the long-ago-left engineer. It’s generally a call from js

  • 0

I have some code from the long-ago-left engineer.
It’s generally a call from js to ASP.NET webservice.

The core lines of js was:

var url1="WebService.asmx";
xmlhttp.open("POST", url1, false);
xmlhttp.setRequestHeader("Content-Type","text/xml;charset=gb2312");

var url2="http://mysite.com/save";
xmlhttp.setRequestHeader("SOAPAction", url2);

xmlhttp.send(data);

var result;
var resultTxt;
result = xmlhttp.status;
returnTxt = xmlhttp.responseText;

xmlhttp = null; 
if(result==200) { 
    if(returnTxt.indexOf("save succeeded")>-1)
        return "succeeded"
}
return "failed";

The core lines of webservice was:

using (SqlConnection conn = new SqlConnection(connectionString))
{
    SqlCommand cmd = new SqlCommand(sqlSelectString, conn);
    IAsyncResult ASynResult;
    SqlDataReader dr;
    try
    {
        conn.Open();
        ASynResult = cmd.BeginExecuteReader(CommandBehavior.CloseConnection);
        while (!ASynResult.IsCompleted)
        {
            ASynResult.AsyncWaitHandle.WaitOne(3000, true);
        }
        dr = cmd.EndExecuteReader(ASynResult);
        value = "save succeeded!!";
    }
    catch
    {
        value = "save failed!!";
    }
}

My question is:

1 Whether this is Asynchronous or Synchronous?

2 Why use IAsyncResult in webservice?

  • 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-05-26T09:20:55+00:00Added an answer on May 26, 2026 at 9:20 am

    Its using an asynchronous command, but waiting so in effect its synchronous. I’m not sure what the original intent was. There are valid reason to have web services utilize the IAsyncReqult pattern having to do with using up threads that IIS needs, but that’s not the way to do it. I’m not sure if its an issue with the current version of IIS either. Here is an old link to some info on it, but there may be more present information out there.

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

Sidebar

Related Questions

I have some code that I borrowed from a long while ago that sets
Does anyone have some code that will take a TimeZoneInfo field from .NET and
I have some code handed from someone long gone to another department. It purports
I have inherited some code (from zip file) from a developer and git initialzed,
I have some code to read from a pdf file. Is there a way
I have ported some LGPL code from Java to C#, which I plan to
I have taken over some code from a previous developer and have come across
Imagine I have some code to read from the start to end of a
I have some code which collects points (consed integers) from a loop which looks
I have some code that will be accessed from two threads: class Timer{ public:

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.