473,385 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Async web method invocation

Hi there,

I'm quite a newbie in Web Service programming/using and I'm sorry if my
question could sound quite "stupid". ;-)

I'm working on an application which should request a service to a
WebService, calling its method "FooMethod(...args...)". I've imported
the web reference within my VisualStudio project and tryed to invoke the
method. I noticed that the intellisense expose also:
- an "AsyncFooMethod(...args...(+1 overloads))";
- a "CompleteFooMethod" event;
I supposed they're for async method invocation, right?
So, could you suggest me any "for-very-dummy" resource to learn how to
use them? Expecially examples and code snippets would be appreciated.

Thanks in advance,
Giulio

--
OnAir: L'Aura - "Turn Around"
Oct 2 '07 #1
3 2526
Giulio Petrucci wrote:
Hi there,

I'm quite a newbie in Web Service programming/using and I'm sorry if my
question could sound quite "stupid". ;-)
As they say, "there are no stupid questions".

Based on past experience with a small minority of questioners, I might
amend that, qualifying the statement with "...as long as the questions
are asked in earnest and the questioner is open to the answers, even if
they don't necessarily like the answer". But IMHO, this qualification
is almost always assumable. :)
I'm working on an application which should request a service to a
WebService, calling its method "FooMethod(...args...)". I've imported
the web reference within my VisualStudio project and tryed to invoke the
method. I noticed that the intellisense expose also:
- an "AsyncFooMethod(...args...(+1 overloads))";
- a "CompleteFooMethod" event;
I haven't used WebService. Sounds like an ASP.NET-specific thing, and
if so there is a newsgroup that is specific to ASP.NET questions that
might be a better place to ask that.

That said...
I supposed they're for async method invocation, right?
So, could you suggest me any "for-very-dummy" resource to learn how to
use them? Expecially examples and code snippets would be appreciated.
MSDN has many good code samples, IMHO. In a cursory search, I wasn't
able to find anything related to WebService that looked like the naming
pattern you describe, so I can't confirm for the specific things you're
talking about. If you're having trouble finding or using the code
samples, you might want to post actual names of classes and methods
you're trying to use.

The basic idea, however, should be simple and should follow the same
asynchronous design other parts of .NET have. Specifically, you call a
method that starts with "Begin..." or "Async...", providing a callback
delegate method (generally you can just write as a parameter the name of
the method you want called when the operation completes). Then in that
callback method, you call the "End..." or "Complete..." method to finish
the operation.

(Note: I'm making some assumptions about the "Async..." and
"Complete..." versions, that they are similar if not identical to the
"Begin..." and "End..." pattern. I haven't actually run into the
Async/Complete naming scheme before, so hopefully it's a valid
assumption to make :) ).

If the operation uses the IAsyncResult interface, you can also check for
completion using an event handle or flag property found in the
IAsyncResult instance, but IMHO the callback is usually the more
convenient and practical mechanism to use.

Pete
Oct 2 '07 #2
The Async methods are a great way to bring some basic multi-threading to
your application.

Here are the relevent MSDN docs, complete with examples in C# & VB.Net:

[Start here, great overview, lots 'o links]
http://msdn2.microsoft.com/en-us/lib...yf(VS.80).aspx

[This is one of those links - "How To:"]
http://msdn2.microsoft.com/en-us/lib...k1(VS.80).aspx

--
Chris Mullins
http://www.coversant.net/blogs/cmullins
"Giulio Petrucci" <fa******@fakedomain.comwrote in message
news:eM**************@TK2MSFTNGP03.phx.gbl...
Hi there,

I'm quite a newbie in Web Service programming/using and I'm sorry if my
question could sound quite "stupid". ;-)

I'm working on an application which should request a service to a
WebService, calling its method "FooMethod(...args...)". I've imported the
web reference within my VisualStudio project and tryed to invoke the
method. I noticed that the intellisense expose also:
- an "AsyncFooMethod(...args...(+1 overloads))";
- a "CompleteFooMethod" event;
I supposed they're for async method invocation, right?
So, could you suggest me any "for-very-dummy" resource to learn how to use
them? Expecially examples and code snippets would be appreciated.

Thanks in advance,
Giulio

--
OnAir: L'Aura - "Turn Around"

Oct 2 '07 #3
"Peter Duniho" <Np*********@NnOwSlPiAnMk.comwrote:
I haven't used WebService. Sounds like an ASP.NET-specific thing, and if
so there is a newsgroup that is specific to ASP.NET questions that might
be a better place to ask that.
Well, these days it's not that simple. Web Services have since become
Services (what that does to a Windows Service, is somewhat of a terminology
mystery), which don't need any of the ASP.Net or even IIS...

WCF has changed the game there, and made what used to be a Web Service into
the generic thing for out-of-proecss communication.
(Note: I'm making some assumptions about the "Async..." and "Complete..."
versions, that they are similar if not identical to the "Begin..." and
"End..." pattern. I haven't actually run into the Async/Complete naming
scheme before, so hopefully it's a valid assumption to make :) ).
It's a pretty valid asumption in most cases. With that said, there are some
instances where that pattern is used and has some "unexpected" threading
implications:
- the BackgroundWorker in Winforms will make sure your event fires on
the right thread, eliminating much of the complexity that traps people.
- The ASP.Net AsyncOperationManager can, I believe, sometimes get
involved in the fray, and help insure things such as your Context are
correct when the even fires (I'm not quite sure about this one. I haven't
personally used it).

Overall, it's a pattern simply designed to not scare off people new to the
world of Async Programming.
[...] IMHO the callback is usually the more convenient and practical
mechanism to use.
I tend to agree, as I've been using them for years and the pattern is very
widespread. However, all that passing around state, and dealing the
IAsyncResult realy confuses many people.

--
Chris Mullins
Oct 2 '07 #4

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

Similar topics

8
by: Dave | last post by:
I'm using the BeginInvoke method of a delegate to invoke a thread asynchronously and then use the EndInvoke to retrieve the value. This works wonderfully until a Serviced Component is added to...
10
by: Shawn Meyer | last post by:
Hello - I am trying to write a class that has an async BeginX and EndX, plus the regular X syncronous method. Delegates seemed like the way to go, however, I still am having problems getting...
8
by: TS | last post by:
Im in a web page and call an asynchronous method in business class. the call back method is in the web page. When page processes, it runs thru code begins invoking the method then the page...
1
by: Simon Hart | last post by:
Hi, I thought I'd just open a thread in an attempt to get peoples feelers with regards to multithreading vs Async Web Service processing. Of course Web Services makes it easy to do Async...
6
by: Shak | last post by:
Hi all, Three questions really: 1) The async call to the networkstream's endread() (or even endxxx() in general) blocks. Async calls are made on the threadpool - aren't we advised not to...
7
by: Shak | last post by:
Hi all, I'm trying to write a thread-safe async method to send a message of the form (type)(contents). My model is as follows: private void SendMessage(int type, string message) { //lets...
0
by: tg | last post by:
Hello, This is more of a design question. I am trying to understand how to use async web service invocation for asp.net 2.0 web parts with an Ajax style update / data rendering. I have a web...
10
by: Frankie | last post by:
It appears that System.Random would provide an acceptable means through which to generate a unique value used to identify multiple/concurrent asynchronous tasks. The usage of the value under...
11
by: nadeem_far | last post by:
Hello, I am working on a c# project using framework 1.1. Since its a console application,no windows forms are being used. I am trying to implement event driven classes that just want to raise...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.