示例#1
0
        public Maybe <Exception> Run()
        {
            try
            {
                if (State != OperationState.Idle)
                {
                    return(null);
                }

                lock (operationLock)
                {
                    if (State != OperationState.Idle)
                    {
                        return(null);
                    }

                    State = OperationState.Running;
                    if (!timestamp.HasValue)
                    {
                        timestamp = keyValueStorage.Find <long>($"{Name}Timestamp.json");
                        if (timestamp.Value == 0)
                        {
                            timestamp = defaultTimestampFunc.Invoke();
                        }
                    }
                    timestamp = enumration.Invoke(timestamp.Value);
                    keyValueStorage.Write($"{Name}Timestamp.json", timestamp.Value);
                    return(null);
                }
            }
            catch (Exception e)
            {
                return(e);
            }
            finally
            {
                State = OperationState.Idle;
            }
        }