title: How to make asynchronous webservice call in C#?
body: <p>This is about a tangled cluster of XHR and WebMethod (asmx). The pattern is simple, I make calls via XHR to Webmethod, but it seems WebMethod are sync not async. I just need to make this transition asynchronous. I am searching and searching (might be not good in search) but couldn't find anything that can resolve this mystery.</p>
  
  <p>Here, how I makes calls via XHR:</p>
  
  <pre><code>$.ajax = {
      pool: [],
      call: function(settings, onSuccess, onFailure) {
          var xhr = new XMLHttpRequest();
          xhr.open(settings.type, settings.location, settings.async);
          xhr.onreadystatechange = function() {
              if (xhr.readyState == 4) {
                  if (xhr.status == 200) {
                      var result = xhr.responseXML.xml.toString();
                      onSuccess($.Encoder.htmlDecode(result));
              }
          };
          $.ajax.pool.push(xhr);
          xhr.send(null);
          return xhr;
      }
  }
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>$.ajax.call({ type: "get", location: "Index.asmx/RaiseCallbackEvent?eventArgument=ramiz.uddin" , async: true }, function(e) {}, function(e){})
  </code></pre>
  
  <p>The webservice is fairly simple too:</p>
  
  <pre><code>    [WebMethod(EnableSession = true)]
      [ScriptMethod(UseHttpGet = true)]
      public string RaiseCallbackEvent(string eventArgument)
      {
        // some logic
        return "&lt;say&gt;hello&lt;/say&gt;";
      }
  </code></pre>
  
  <p>And some web.config entries that allows POST, GET calls:</p>
  
  <pre><code>    &lt;webServices&gt;
        &lt;protocols&gt;
          &lt;add name="HttpSoap"/&gt;
          &lt;add name="HttpPost"/&gt;
          &lt;add name="HttpGet"/&gt;
        &lt;/protocols&gt;
      &lt;/webServices&gt;
  </code></pre>
  
  <p>Could you please guide me what I've to do for asynchronous?</p>
  
  <p>Thanks.</p>