Beispiel #1
0
        private IEnumerator WaitFinishByMoment(float delay)
        {
            float waitTime = (delay + Length) * UnityEngine.Time.timeScale;

            yield return(new WaitForSeconds(waitTime));

            m_finishByMonentCoroutine = null;
            if (!IsLoop)
            {
                onFinish?.Invoke(this);
                onFinish = null;
            }
        }
        protected virtual void ReadFile()
        {
            while (true)
            {
                var next = Dequeue();

                if (next == null)
                {
                    Thread.Sleep(100);
                    continue;
                }

                try
                {
                    if (!lastPositionDict.ContainsKey(next))
                    {
                        lastPositionDict.Add(next, 0L);
                        fileStatistics.Add(next, new TailStatistics());
                    }

                    StartCallback?.Invoke(initialLoad);
                    var totalLineCount = 0;
                    var minLineCount   = 0;
                    var clear          = false;
                    using (var reader = readerFactory.CreateReader(next))
                    {
                        var loadLastLines = LoadLastLines();
                        if (initialLoad && loadLastLines >= 0 && lastPositionDict[next] == 0)
                        {
                            totalLineCount = reader.CountLines();
                            minLineCount   = totalLineCount > loadLastLines ? totalLineCount - loadLastLines : 0;
                        }

                        var lastPosition = lastPositionDict[next];

                        if (lastPosition > reader.Length)
                        {
                            lastPositionDict[next] = lastPosition = 0L;
                            fileStatistics[next].Reset();
                            initialLoad = true;
                            StartCallback?.Invoke(initialLoad);
                            clear = true;
                        }

                        reader.Seek(lastPosition);
                        ReadLines(reader, next, minLineCount, clear);
                        lastPositionDict[next] = reader.Position;
                    }

                    FinishCallback?.Invoke(initialLoad, fileStatistics[next]);
                    initialLoad = false;
                }
                catch (Exception ex)
                {
                    ExceptionCallback?.Invoke(ex);
                }
            }
        }
Beispiel #3
0
        public void Stop(StopAction stopAction)
        {
            if (CurrentState == State.Stopped)
            {
                return;
            }

            CurrentState = State.Stopped;

            switch (stopAction)
            {
            case StopAction.CompleteInterpolationAndCallFinish:
                Time = CurrentConfig.Duration;
                UpdateInterpolation();

                FinishCallback?.Invoke(this);
                break;

            case StopAction.CallFinish:
                FinishCallback?.Invoke(this);
                break;
            }
        }