What is the difference between ExecuteQuery() and ExecuteQueryAsync()?

ExecuteQuery ExecuteQueryAsync
In ClientContext.ExecuteQuery method, operation will be executed synchronously.    In ClientContext.ExecuteQueryAsync method, operation will be executed asynchronously.
The current thread will wait till it gets response from server before continuing.  The current thread will not wait till it gets response from server. 
This is helpful when you want to conditionally execute the next steps based on response from server. You specify callback methods to catch the response from the server.
ExecuteQuery method is used in server object model ExecuteQueryAsync is used in ECMA script object model
Syntax: ClientContext.ExecuteQuery() Syntax: ExecuteQueryAsync(callback success,callback failure)

Here there are two callback parameters.
1)    For success
2)    For Failure 
© 2019 Code SharePoint