Waqas Ahmed
Waqas Ahmed

Reputation: 493

Create CRM entity record with Async approach

I need to create CRM entity record asynchronously. I have implemented multi threading in my code and each thread will be responsible to create an entity record in the CRM. Right now due to the blocking behavior of CRM while creating the entity I am unable to utilize the opened threads.

Following is the code which I want to perform in asynchronous way.

Entity task = new Entity("task");
task["subject"] = "Test Task";
task["description"] = "Testing";
task["regardingobjectid"] =  new EntityReference("account", new Guid("xxxxxxxxxxxx"));
Guid taskid = service.Create(task);

Any help in this regard would be really appreciated.

Upvotes: 0

Views: 1232

Answers (1)

Aron
Aron

Reputation: 3935

Here's a CreateAsync example from the BaseProxyClass of XrmToolkit

using System.Threading.Tasks;
public async Task<Guid> CreateAsync(IOrganizationService service)
{
    return await Task.Run(() => { return this.Create(service); });
}

Upvotes: 1

Related Questions