473,473 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

asynchronous web method calls - begin without end

If I have a web method called Log() and on the client I call
BeginLog() with a null value for the AsyncCallback, will this cause a
problem? I want to periodically Log messages to a Log web service but
I don't need any return value. Is it poor programming practice to do
it this way? Or is there a more preferred way?

gkelly
Jun 27 '08 #1
2 2225
Probably a better approach would be to use the "fire-and-forget" pattern to
make a call to the synchronous webmethod so you don't need to wait for the
method to return, rather than trying to "abuse" the asynchronous version.

Search on "C# Fire and forget" and you'll find several examples including a
couple of my own.
Peter

<gr***********@recursor.netwrote in message
news:78**********************************@z24g2000 prf.googlegroups.com...
If I have a web method called Log() and on the client I call
BeginLog() with a null value for the AsyncCallback, will this cause a
problem? I want to periodically Log messages to a Log web service but
I don't need any return value. Is it poor programming practice to do
it this way? Or is there a more preferred way?

gkelly
Jun 27 '08 #2
On Wed, 14 May 2008 12:36:26 -0700, <gr***********@recursor.netwrote:
If I have a web method called Log() and on the client I call
BeginLog() with a null value for the AsyncCallback, will this cause a
problem? I want to periodically Log messages to a Log web service but
I don't need any return value. Is it poor programming practice to do
it this way? Or is there a more preferred way?
As a general rule, you must call the corresponding "End" method when using
the asynchronous "Begin" method. One notable exception is the
Control.BeginInvoke() method, but that's a very special case.

I don't know the specific answer regarding your Log() method, and your
question sounds a lot more like a web/.ASP question than a more general
C#/.NET question, but I think it's likely that general rule applies here.
Somewhere along the line, you probably should be calling the "End" method.

Note that even if you were to ascertain by inspection that the code
currently doesn't leak anything when you don't call the "End" method,
that's an implementation detail that you should not be relying on. The
standard .NET async API dictates that you should always call the "End"
method.

Pete
Jun 27 '08 #3

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

Similar topics

1
by: Natalia DeBow | last post by:
Hi, I am working on a Windows-based client-server application. I am involved in the development of the remote client modules. I am using asynchronous delegates to obtain information from...
0
by: Jonathan Trevor | last post by:
Hi, I've found what appears to be a bug with ASP.NET web service method invocation - making it impossible to invoke and get the result of a synchronous web call after an asynchronous call has...
5
by: rgarf | last post by:
I have a C++ application that consumes a web service. I would like to call the web service asynchronously so my C++ application can do other processing in between. My proxy file does not have any...
7
by: Siv | last post by:
Hi, I have a stored procedure that I want to execute and then wait in a loop showing a timer whilst it completes and then carry on once I get notification that it has completed. The main reason...
1
by: dba123 | last post by:
I need to perform Asynchronous Inserts using DAAB. So far I have a method which does an insert but how can I do this Asyncronously so that it does not affect the load on our public production...
10
by: Susan | last post by:
I have a process that takes a while to run so I have it running asynchronously so that the user can continue working. My question is that I want to killl the process if the user changes the search...
0
by: Bishoy George | last post by:
Hi, I have a asp.net 2.0 web application. I want to implement the asynchronous model through http handler in web.config ...
6
by: Pat B | last post by:
Hi, I'm writing my own implementation of the Gnutella P2P protocol using C#. I have implemented it using BeginReceive and EndReceive calls so as not to block when waiting for data from the...
2
by: =?Utf-8?B?S2FseWFu?= | last post by:
Hi, I have to make multiple calls (about 400K) to a webservice which returns a string. And currently it takes about a week to make all the calls. Instead of waiting for the webservice result ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
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 ...
0
muto222
php
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.