views:

280

answers:

5

I need someone to explain the following names;

  1. Asynchronous Delegates.
  2. Asynchronous methods.
  3. Asynchronous events.

I'm currently going over this for my 70-536 exam and I am covering all my bases so far. The threading chapter and online resources have been good to me on my second read through. Still though, the names used above mean absolutely nothing to me? I would really appreciate the meaning behind the word 'Asynchronous' and its relevance to Delegates, methods and events.

Feel free to go into as much detail as you like.

Thanks, Ibrar

UPDATE:

Thanks for all the replies. Hopefully this question will be helpful to other novice and inexperienced developers. Oh for the record I do know the difference between sync and async. I was just getting confused with the names that's all.

This not homework :( .... I saw the asynchronous words quite a few times on my first exam so I'm just covering my bases really. Technically its, Exam Prep !!!

+3  A: 

See the section in the .NET documentation on Asynchronous Programming Using Delegates.

In summary, delegates have a BeginInvoke method that lets you call them asynchronously. When called, the target method is started in a separate thread. The invoking thread can receive a call back when the target method completes and can call EndInvoke on the delegate to retrieve the results.

Phil Ross
ty for this. I will have a gander at that.
IbrarMumtaz
+4  A: 

I am a believer in studying and finding your answers when it comes to an exam.

Here are some articles

Read the wiki on it: http://en.wikipedia.org/wiki/Asynchronous_communication

Or here on "What is async", this one is short and to the point: http://www.webopedia.com/TERM/A/asynchronous.html

On example is say in my code, i have a serial port. One thread reads and one thread writes to the port. I can read and write at the same time (sort of) so this is ASYNC. If i were blocking the incomming data while i am writting then i would be synchronous.

Lily
the webopedia is a great link !!! thanks for that.Taking a look at the Wikipedia link now. *Yipes* :p
IbrarMumtaz
+2  A: 

Given what you posted, I'll assume that you know the distinction between asynchronous and synchronous execution.

An asynchronous delegate (and, by extension, an asynchronous event) simply means that the underlying method is (or methods are!) invoked in an asynchronous manner.

An asynchronous method is one that performs an asynchronous operation (heh).

Sorry for being vague, but if you understand what asynchronous means then this should point you in the right direction.

Adam Robinson
+11  A: 

'Asynchronous' describes a type of execution flow.

Synchronous instructions execute linearly and prevent subsequent instructions from executing until complete (that is, they block). So given the following synchronous code:

DoOneThing();
DoAnotherThing();

DoAnotherThing doesn't execute until DoOneThing is finished.

Asynchronous instructions differ in that you don't know (or sometimes even care) when they start or finish executing. In a case like this:

DoOneAsynchronousThing();
DoAnotherThing();

The first statement initiates the asynchronous operation, then does another thing immediately before the first operation is completed (or perhaps even started).

There are many different mechanisms for providing asynchronous execution: the most common ones (at least in the .NET world) are probably the ThreadPool (for in-process asynchronous execution) and Microsoft Message Queue (for inter-process asynchronous execution). For a .NET-specific introduction, you might start with this MSDN topic, "Including Asynchronous Calls".

So asynchronous delegates, methods, and events all run (and complete) at indeterminate times and do not block the main thread of execution.

Jeff Sternal
This seems like an awful lot of information to give a homework-related question.
Adam Robinson
The question is answered concisely and thoroughly, so I don't see any reason to complain. Besides, a certification exam isn't exactly 'homework-related.'
Rob
@Adam - it may have been overkill, but it didn't take long to write, and I figured other users might get some use out of it someday. (Though probably not with the current title and tags.)
Jeff Sternal
@Rob concise and thorough are frequently mutually-exclusive. Occasionally accuracy must be sacrified for the sake of clarity.
David Lively
@ Jeff - I edited the title of my question; hopefully now it might be alot clearer when casually browsing search and similar related listings.
IbrarMumtaz
@David -- of course. But both terms must be taken in context. I meant that he answered the question clearly and without wordiness, while still retaining the essential information.
Rob
+1  A: 

If you execute something synchronously, your app waits on the result: for example, ordering a burger at a drivethrough. You're pretty much stuck in line until the task (burger prep, billing and delivery) is complete.

If you execute asynchronously, you do other things instead of waiting: for example, ordering a pizza and watching a movie while waiting on it to be delivered.

David Lively