By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,084 Members | 1,199 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,084 IT Pros & Developers. It's quick & easy.

Async web method invocation

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.