Click here to Skip to main content
15,913,279 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Pls some one tell that

What is asynchronous and synchronous callback

I dont have idea about this, Pls some one tell......
Posted
Comments
[no name] 28-Sep-13 9:37am    
Do you know how to search for answer to questions like this using google?

synchronous means it makes a call and waits for a response.

asynchronous means it makes a call and carries on doing other stuff then recieves a response some time later
 
Share this answer
 
 
Share this answer
 
Callbacks, synchronous and asynchronous[^] is a great blog for information on this topic.
 
Share this answer
 
A synchronous call means control waits till the operation is complete before moving to the next statement.
Example:

C#
Class Main()
{
var ResultOfA = ProcessA(); //Only upon completion of this method, the control can move to next line to process method ProcessB() and then to subsequent methos.
ProcessB();
ProcessC();
ProcessD(ResultOfA);
}


In Asynchronous call

If you decide to call ProcessA, ProcessB and ProcessC in parallel (as only ProcessD requires ProcessA to complete to receive the parameters).

It goes like this:

XML
        Task<string> t1 = Task<string>.Factory.StartNew(() => a.ProcessA());
        Task t2 = Task.Factory.StartNew(() => a.ProcessB());
        Task t3 = Task.Factory.StartNew(() => a.ProcessC());
        Task.WaitAll(t1, t2, t3);

        a.ProcessD(t1.Result);
</string></string>


This means as soon as the method A is called, the control, without waiting for its completion, executes the next line which is to processB and same happens untill it reaches the statement Task.WaitAll() which forces the control to wait till all the three methods complete before executing the fourth method ProcessD.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900