/// <summary> /// Adds a new <see cref="GroupDefinition"/> to the graph and returns the ID for that group. /// </summary> /// <param name="id">The ID of the group.</param> /// <param name="group">The group that should be added to the graph.</param> /// <returns>A task that will finish when the action has completed.</returns> public Task Add(GroupCompositionId id, GroupDefinition group) { var globalTask = Task.Factory.StartNew( () => { var key = m_DatasetLock.LockForWriting(); try { m_CompositionLayer.Add(id, group); } finally { m_DatasetLock.RemoveWriteLock(key); } }); return(globalTask); }
/// <summary> /// Indicates that the dataset should prepare to execute a sequence. /// </summary> /// <returns>A task that will complete once the dataset is ready for executing.</returns> public Task SwitchToExecuteMode() { return(Task.Factory.StartNew( () => { DatasetLockKey key; if (m_EditKeys.TryPop(out key)) { m_DatasetLock.RemoveWriteLock(key); } }, TaskCreationOptions.LongRunning)); }