private void Unlock()
            {
                var dateMax = WorkflowClock.Now().AddMinutes(5);

                while (WorkflowClock.Now() < dateMax)
                {
                    if (this.disposedValue)
                    {
                        return;
                    }

                    Thread.Yield();
                }

                throw new TimeoutException();
            }
        public Workflow CreateNewWorkflow(string workflowName, int workflowVersion, string externalkey, DynObject extendedDatas)
        {
            Workflow wrk = GetWorkflow(workflowName, workflowVersion);

            wrk.Uuid           = Guid.NewGuid();
            wrk.WorkflowName   = workflowName;
            wrk.Version        = workflowVersion;
            wrk.ExternalId     = externalkey;
            wrk.CreationDate   = WorkflowClock.Now();
            wrk.LastUpdateDate = WorkflowClock.Now();
            wrk.Concurency     = 1;
            wrk.Change         = ChangeEnum.New;

            if (extendedDatas != null)
            {
                wrk.ExtendedDatas().Merge(extendedDatas);
            }

            return(wrk);
        }