internal async Task RunAsyncCore(IIdle idle, CancellationToken cancellationToken)
        {
            Settings.Reload();

            await RunAsyncOverride(cancellationToken).ConfigureAwait(false);

            TelemetryClient.Flush();

            // Perform an eager garbage collection before entering an idle period. Otherwise, the GC performs garbage
            // collection at the beginning of the next cycle and uses up resources when they're actually needed.
            GCCollect();

            idle.WriteTimeRemaining();

            var remaining = idle.GetTimeRemaining();

            if (remaining > Settings.DelayBeforeGC)
            {
                await Task.Delay(Settings.DelayBeforeGC, cancellationToken).ConfigureAwait(false);

                GCCollect();
            }

            await idle.DelayAsync(cancellationToken).ConfigureAwait(false);
        }
Ejemplo n.º 2
0
    public void RegisterIdle(IIdle iIdle, float time)
    {
        if (idle_object.Contains(iIdle))
        {
            return;
        }

        idle_object.Add(iIdle);

        handle_idle_enumerator.Add(Timing.RunCoroutine(enumerator_idle(iIdle, time)));
    }
Ejemplo n.º 3
0
    public void UnRegisterIdle(IIdle idle)
    {
        var indexOf = idle_object.IndexOf(idle);

        if (indexOf < 0)
        {
            return;
        }

        Timing.KillCoroutines(handle_idle_enumerator[indexOf]);

        idle_object.RemoveAt(indexOf);
        handle_idle_enumerator.RemoveAt(indexOf);
    }
Ejemplo n.º 4
0
    private IEnumerator <float> enumerator_idle(IIdle iIdle, float time)
    {
        yield return(Timing.WaitForSeconds(Random.Range(0.0f, 1.0f)));

        while (!iIdle.IsStop())
        {
            yield return(Timing.WaitForSeconds(time));

            //iIdle.EarnCoins ();

            //this.PlayAudioSound (AudioEnums.SoundId.TapOnItem);

            //if (Random.Range (0.00f, 1.00f) < 0.25f)
            //{
            //    this.PlayAudioSound (AudioEnums.SoundId.ItemTouchTalk);
            //}
        }
    }