473,662 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

simple asynch web request question

Hi everyone, I have what I think is a simple question concerning
making an asynchronous web request using the BeginGetRespons e /
EndGetResponse methods of httpWebRequest.

My app needs to fire off a bunch (possibly thousands) of http requests
at once. Each request calls a java servlet which places a telephone
call. I need to examine the stream returned and do a simple SQL
update to log the status of the call. Unfortunately the info returned
by the servlet is pretty minimal and doesn't include any information
other than success, busy, no_answer, etc..

What I need to be able to do is identify which call each status
message relates to. However, I can't quite figure out how to do this
=( Is the state object what I should be paying attention to here? Is
there a way to make the phone number available to the callback
delegate that is receiving the response stream?

For instance to initate the request:

----------
string URI = "http://xxx.xxxx.com/connect-Phone?phone_num ber=555-555-5555";

HttpWebRequest req = (HttpWebRequest ) WebRequest.Crea te(fullURI);

RequestState myRequestState = new RequestState(no tificationId);

myRequestState. request = req;

IAsyncResult result = (IAsyncResult) req.BeginGetRes ponse(new
AsyncCallback(R espCallback),my RequestState);
------------

How can I get the 555-555-5555 as a variable to use in my SQL queries
held within RespCallback?
Many many thanks for any help anyone can offer!
Nov 15 '05 #1
2 1534
MT404,

Yes, it's the state object you need to use.
See this articles from MSDN to understand how it is done.

--
Sorin Dolha [MCP, MCAD, MCSD]
"mt404" <mt*******@hotm ail.com> wrote in message news:67******** *************** ***@posting.goo gle.com...
Hi everyone, I have what I think is a simple question concerning
making an asynchronous web request using the BeginGetRespons e /
EndGetResponse methods of httpWebRequest.

My app needs to fire off a bunch (possibly thousands) of http requests
at once. Each request calls a java servlet which places a telephone
call. I need to examine the stream returned and do a simple SQL
update to log the status of the call. Unfortunately the info returned
by the servlet is pretty minimal and doesn't include any information
other than success, busy, no_answer, etc..

What I need to be able to do is identify which call each status
message relates to. However, I can't quite figure out how to do this
=( Is the state object what I should be paying attention to here? Is
there a way to make the phone number available to the callback
delegate that is receiving the response stream?

For instance to initate the request:

----------
string URI = "http://xxx.xxxx.com/connect-Phone?phone_num ber=555-555-5555";

HttpWebRequest req = (HttpWebRequest ) WebRequest.Crea te(fullURI);

RequestState myRequestState = new RequestState(no tificationId);

myRequestState. request = req;

IAsyncResult result = (IAsyncResult) req.BeginGetRes ponse(new
AsyncCallback(R espCallback),my RequestState);
------------

How can I get the 555-555-5555 as a variable to use in my SQL queries
held within RespCallback?
Many many thanks for any help anyone can offer!
Nov 15 '05 #2
"Sorin Dolha [MCSD]" <sd****@hotmail .com> wrote in message news:<O4******* *******@TK2MSFT NGP09.phx.gbl>. ..
MT404,

Yes, it's the state object you need to use.
See this articles from MSDN to understand how it is done.


Sorin,

I was able to get things working exaclty how I was hoping by creating
a class which I passed the data I needed to access in the callback
delegate to. I then used an instance of this class as the state
object for the async web request, and voila, I had everything working
exactly as I was hoping.

Thanks for confirming that I was barking up the right tree.

-Matt
Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2821
by: malcolm | last post by:
I've seen several posts around the Internet and many of them either don't work or only partially work. All I'm trying to do is record some action asynchronously from an html file, a sort of logging mechanism. The product is a CD catalog that will be delivered to many customers and they want the ability to log specific pages accross the Internet, and there's no gaurantee these people will be connected to the Internet, the ones that are...
11
1758
by: Glen Wolinsky | last post by:
This is my first attempt as asynchronous processing. I have created a small test app as proof of concept, but I am having one proglem. In the example (code listed below), my callback routine has two problems: 1. It runs TWICE; and 2. While it seems to update the web page controls, the results never show up on the page. I am using delegates per a couple of examples I found on MSDN and elsewhere.
2
1538
by: ghost | last post by:
As the Subject indicates I have written a web page that makes use of several web service calls. Some of the web service calls are very fast so they called synchronously. Some web service calls are longer running so I call them asynch so that they can all run concurrently. The user base for the application that I am creating demands the partial response of the faster calls and a gradual update of their web page info from the balance of...
5
1840
by: Ric | last post by:
I created a page in ASP.Net (with no buffering) that does the following: Output line #1 FLUSH {wait 1 second} Output line #2 {wait 1 second} Output line #3 FLUSH
2
1089
by: Techno_Dex | last post by:
What is the correct way to debug a WS which makes it's call Asynch?
1
2638
by: Sean | last post by:
I am looking at using delegates to perform an asynchronous call. There will be a callback invoked at the end of the call. The client thread will wait on the WaitHandle from IAsyncResult (which is really a AsyncResult). My question is, when exactly is this WaitHandle signalled - is it: -when the asynchronous call finishes OR -when EndInvoke() is called (by the callback)
4
1861
by: EM_J | last post by:
I am implementing this interface in one of my pages. The RaiseCallbackEvent method runs a task for about 3 seconds. I've noticed when I am on that page and click a tab to navigate to another page, it may take up to 3 seconds to redirect. If I decrease the time to 500 ms, the redirect happens much faster. So it seems like this asynch task is not really asynch, since the redirect is waiting for it to complete. Am I misunderstanding...
0
1148
by: =?Utf-8?B?aGVyYmVydA==?= | last post by:
I have a messaging API which creates notification responses for multiple requests ( interfacing a device on SerialPort class). So I created a layer following the event-based asynchronous pattern. The request is sent to RS-232 using MethodNameAsynch() and the response creates an event. There are multiple methodnameAsynch() calls and events, each of them can be called multiple times using userState objects. Now I want to wrap this layer...
17
5807
by: Chris M. Thomasson | last post by:
I use the following technique in all of my C++ projects; here is the example code with error checking omitted for brevity: _________________________________________________________________ /* Simple Thread Object ______________________________________________________________*/ #include <pthread.h> extern "C" void* thread_entry(void*);
0
8435
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8768
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8547
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7368
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5655
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4348
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.