Commit exception in Telerik OpenAccess ORM

627 Views Asked by At

I had a previous question similar to this one, but in regards to entity framework. Since then, I have tried using Telerik OpenAccess. Here is my model:

enter image description here

When running through the following function about once every 10 seconds, it behaves as expected and does not through an exception. However, if I 3 concecutive calls to this function, within a short time, I am getting this error.

InvalidOperationException - Not allowed because Commit / Rollback is in progress

Here is the function. The exception is thrown on SaveChanges()

private void NewTaskTaskCompleted(object sender, TaskCompletedEvent e)
{
    TASK scheduledTask = entities.TASKs.First(x => x.TASK_NAME == e.ClassName);
    scheduledTask.NEXT_RUN = e.NextRun;
    //entities.SaveChanges();

    TASK_LOG logMsg = new TASK_LOG()
    {
        TASK = scheduledTask,
        MESSAGE = e.TaskResult.Message,
        STATUS = e.TaskResult.Status ? "Successful" : "Failure",
        TIMESTAMP = e.CompletedTime
    };

    scheduledTask.TASK_LOGs.Add(logMsg);
    //entities.Add(logMsg);
    entities.SaveChanges();
}

Does the SaveChanges call not block the function from exiting, preventing the next function call from occurring?

1

There are 1 best solutions below

0
On

Telerik has as standard an Optimistic concurrency behaviour. Meaning: It is asumed that no concurrency happens, if it happens, it will crash. There is no check before, so either you use an own mechanism (like a lock).

See also http://www.telerik.com/help/openaccess-orm/concurrency-control-pessimistic.html