Exemplo n.º 1
0
        /// <summary>
        /// Load most recent logs from temporary file
        /// </summary>
        public override void LoadLastLogs()
        {
            LogEntryCollection.StartRemovingFromTop();
            LogEntryCollection.Clear();

            uint entriesNumber;
            bool success = Log9KUtil.GetEntriesNumberInFile(
                FilenameTempFile, Log9KEntry.ENTRY_SIZE, out entriesNumber
                );

            if (!success)
            {
                Log9KCore.Instance.InnerLog("Ошибка: метод Log9KUtil.GetEntriesNumberInFile вернул false");
                return;
            }

            if (Application.Current == null)
            {
                return;
            }
            Application.Current.Dispatcher.BeginInvoke(
                new Action(() => {
                bool notEnd = true;
                uint z      = 0;
                for (uint i = entriesNumber; notEnd; i--)
                {
                    Log9KEntry e = ReadEntry(i);
                    if (e != null)
                    {
                        LogEntryCollection.Insert(0, e);
                    }
                    if (i == 0 || z >= LogEntryCollection.MaxCollectionSize)
                    {
                        notEnd = false;
                    }
                    z++;
                }
            }),
                DispatcherPriority.Background
                );
        }