{"id":11096,"date":"2011-07-25T09:29:33","date_gmt":"2011-07-25T09:29:33","guid":{"rendered":"https:\/\/www.techopedia.com\/definition\/asynchronous-method-call\/"},"modified":"2011-08-18T17:21:32","modified_gmt":"2011-08-18T17:21:32","slug":"asynchronous-method-call","status":"publish","type":"definition","link":"https:\/\/www.techopedia.com\/definition\/25584\/asynchronous-method-call","title":{"rendered":"Asynchronous Method Call"},"content":{"rendered":"
An asynchronous method call is a method used in .NET programming that returns to the caller immediately before the completion of its processing and without blocking the calling thread.<\/p>\n
When an application calls an asynchronous method, it can simultaneously execute along with the execution of the asynchronous method that performs its task. An asynchronous method runs in a thread separate from the main application thread. The processing results are fetched through another call on another thread. <\/p>\n
Asynchronous methods help optimize the execution of resources resulting in scalable application. These are used to execute time-consuming tasks such as opening large files, connecting to remote computers, querying a database, calling Web services and ASP.NET Web forms.<\/p>\n
Asynchronous method call may also be referred to as asynchronous method invocation (AMI).<\/p>\n
Asynchronous method differs from synchronous method in the manner in which it returns from the call. While an asynchronous method call returns immediately, allowing the calling program to perform other operations, synchronous method calls wait for the method to complete before continuing with program flow.<\/p>\n
The .NET framework has inbuilt asynchronous infrastructure so that any method can be asynchronously invoked without altering its code.<\/p>\n
.NET framework provides two design patterns to implement the asynchronous method, which are those using asynchronous delegates (IASyncResult objects) and events. Asynchronous delegates’ pattern is more complex and provides flexibility, which makes it well-suited to various complex programming models. The event-based model is simple and should be used in most cases. <\/p>\n
In the asynchronous delegates pattern, a delegate object uses two methods: BeginInvoke and EndInvoke. BeginInvoke has a list of parameters, which are similar to its wrapped function, along with two additional optional parameters; it returns the IAsyncResult object. EndInvoke returns two parameters (out and ref type) along with the IAsyncResult object. BeginInvoke is used for initiating the asynchronous call, whereas EndInvoke is used to retrieve the results of the asynchronous call.<\/p>\n
Events-based asynchronous patterns use a class that has one or more methods, named MethodNameAsync, which have corresponding synchronous versions that execute on the current thread. Events-based patterns may also have a MethodNameCompleted event and MethodNameAsyncCancel method. This pattern enables the class to communicate with pending asynchronous operations using the delegate event model. <\/p>\n
The following are a few tips related to asynchronous methods:<\/p>\n
What Does Asynchronous Method Call Mean? An asynchronous method call is a method used in .NET programming that returns to the caller immediately before the completion of its processing and without blocking the calling thread. When an application calls an asynchronous method, it can simultaneously execute along with the execution of the asynchronous method that […]<\/p>\n","protected":false},"author":7813,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"_acf_changed":false,"_lmt_disableupdate":"","_lmt_disable":"","om_disable_all_campaigns":false,"footnotes":""},"definitioncat":[273,244,216],"class_list":["post-11096","definition","type-definition","status-publish","format-standard","hentry","definitioncat-devops","definitioncat-programming-languages","definitioncat-software-development"],"acf":[],"yoast_head":"\n