Exemplo n.º 1
0
        public Task StartAsync(CancellationToken stoppingToken)
        {
            logger.LogInformation("CleanUpService started");

            if (cleanUpOptions == null)
            {
                throw new ArgumentNullException(nameof(cleanUpOptions));
            }

            if (cleanUpOptions.IntervalInSeconds < 0)
            {
                throw new ArgumentException("Interval cannot be less than zero");
            }

            using (var serviceScope = serviceScopeFactory.CreateScope())
            {
                var cleanable = serviceScope.ServiceProvider.GetRequiredService <ICleanable>();

                if (cleanable == null)
                {
                    throw new Exception("Failed to get ICleanable service");
                }

                actionRepeater = new ActionRepeater(cleanUpOptions.IntervalInSeconds, cleanable.CleanUp);
            }

            return(Task.CompletedTask);
        }
Exemplo n.º 2
0
        public void TrainNetwork(MNistImage[] images, CancellationToken cancellation)
        {
            Debug.AssertNotNull(images);
            Debug.Assert(cancellation != null);
            if (_statRefresher != null && _statRefresher.Started)
            {
                return;
            }

            _cancelTrainToken = cancellation;

            var normalImages = new NormalizedImage[images.Length];

            for (var i = 0; i < images.Length; i++)
            {
                normalImages[i] = new NormalizedImage(images[i]);
            }

            _statRefresher = new ActionRepeater(PrintTrainingInfo, 1000.0);
            _statRefresher.Start(false);

            TrainProcess(normalImages);

            _statRefresher.Stop(true);
            History = txtStatistics.Text;
        }
Exemplo n.º 3
0
        public void TestNetwork(MNistImage[] images, CancellationToken cancellation)
        {
            Debug.AssertNotNull(images);
            Debug.AssertNotNull(cancellation);

            if (_statRefresher != null && _statRefresher.Started)
            {
                return;
            }

            _cancelTrainToken = cancellation;

            var normalImages = new NormalizedImage[images.Length];

            for (var i = 0; i < images.Length; i++)
            {
                normalImages[i] = new NormalizedImage(images[i]);
                normalImages[i].PadCanvas(Network.InputImageWidth, Network.InputImageHeight);
            }

            _testInfoBuffer.Clear();
            _imageProcessed = 0;
            _errors.Clear();
            _totalMSE = 0.0;

            _statRefresher = new ActionRepeater(PrintTestingInfo, 1000.0);
            _statRefresher.Start(false);

            TestProcess(normalImages);

            _statRefresher.Stop(true);
            History = txtStatistics.Text;
        }
Exemplo n.º 4
0
    public FracturedDaysSplitTheSky() : base(
            new SpiritPresence(
                new PresenceTrack(Track.Energy1, Track.Energy1, Track.Energy2, Track.Energy2, Track.Energy2, Track.Energy2),
                new PresenceTrack(Track.Card1, Track.Card1, Track.Card1, Track.Card2, Track.Card2, Track.Card3)
                )
            , PowerCard.For <AbsoluteStatis>()
            , PowerCard.For <BlurTheArcOfYears>()
            , PowerCard.For <PourTimeSideways>()
            , PowerCard.For <ThePastReturnsAgain>()
            )
    {
        var g2Repeater = new ActionRepeater(2);
        var g3Repeater = new ActionRepeater(3);

        Growth = new Growth(
            new GrowthOption(
                new Gain1Element(Element.Air),
                new ReclaimAll(),
                new GainTime(2)
                ),
            new GrowthOption(
                new Gain1Element(Element.Moon),
                new DrawPowerCard(),
                new PlacePresence(2),
                g2Repeater.Bind(new GainTime(1)),
                g2Repeater.Bind(new PlayExtraCardThisTurn(2))
                ),
            new GrowthOption(
                new Gain1Element(Element.Sun),
                new DrawPowerCardFromDaysThatNeverWere(),
                new MovePresence(4),
                g3Repeater.Bind(new GainTime(1)),
                g3Repeater.Bind(new GainEnergy(2))
                )
            );

        InnatePowers = new InnatePower[] {
            InnatePower.For <SlipTheFlowOfTime>(),
            InnatePower.For <VisionsOfAShiftingFuture>()
        };

        DtnwMinor = new List <PowerCard>();
        DtnwMajor = new List <PowerCard>();
        decks.Add(new SpiritDeck {
            Icon = Img.Deck_DaysThatNeverWere_Minor, PowerCards = DtnwMinor
        });
        decks.Add(new SpiritDeck {
            Icon = Img.Deck_DaysThatNeverWere_Major, PowerCards = DtnwMajor
        });
    }
Exemplo n.º 5
0
 void Start()
 {
     rg             = GetComponent <Rigidbody>();
     actionRepeater = new ActionRepeater(() => 0.5f, ApplyForce);
 }
 public static ActionRepeater Repeat(this Action action, TimeSpan delay, CancellationToken cancellationToken, TextWriter outputter = null)
 {
     return(ActionRepeater.Start(action, delay, cancellationToken, outputter));
 }
Exemplo n.º 7
0
 void Start()
 {
     actionRepeater = new ActionRepeater(() => 3, GenerateRandomEvent);
 }
Exemplo n.º 8
0
 protected override void Start()
 {
     base.Start();
     actionRepeater = new ActionRepeater(() => Random.Range(3, 3), GoToRandomPoint);
 }
 internal RepeatableActionFactory(GrowthActionFactory inner, ActionRepeater repeater)
 {
     this.Inner    = inner;
     this.repeater = repeater;
     repeater.Register(this);
 }