The new Dynamics CRM 2013 SDK includes a new method to execute service requests asynchronously which currently only works for asynchronous solution imports at the time of this writing. The main benefit of an asynchronous solution import is that there is less of an effect on users who are interacting with the system when the solution is being imported. Previously, users would get locked out and would experience a SQL Server error during import.
The following code snippet can be used to execute an asynchronous solution import in CRM 2013.
var connection = new CrmConnection("Crm");
var service = new OrganizationService(connection);
var context = new CrmOrganizationServiceContext(connection);
IOrganizationService sdk = (IOrganizationService)context;
ExecuteAsyncRequest request = new ExecuteAsyncRequest
Request = new ImportSolutionRequest
CustomizationFile = File.ReadAllBytes(pathToSolutionFile),
PublishWorkflows = true,
ExecuteAsyncResponse response = (ExecuteAsyncResponse)sdk.Execute(request);