Beispiel #1
0
        private void StartParseLog(string fileName)
        {
            run = false;

            inputStream = File.OpenText(fileName);

            Title = fileName;
            FileInfo f = new FileInfo(fileName);

            Title         += " " + f.Length / 1024 + "k";
            currentLogFile = fileName;
            currentLogSize = f.Length;
            currentTitle   = Title;
            string fileExt = Path.GetExtension(currentLogFile).ToLower();

            //isCSV = currentLogFile.ToUpper().EndsWith(".CSV");
            switch (fileExt)
            {
            case LogFileExtension.CSV:
                logParser = new CSVParser();
                break;

            case LogFileExtension.ASC:
                logParser = new VectorASCParser();
                break;

            default:
                logParser = null;
                break;
            }

            //runningTasks.Clear();
            timer?.Dispose();
            timer = null;

            foreach (var v in parser.items.Values)
            {
                if (v.Points == null)
                {
                    v.Points = new ConcurrentStack <DataPoint>();
                }
                else
                {
                    v.Points.Clear();
                }
            }

            if (thread != null)
            {
                thread.Join();
            }
            //thread.Abort();

            timer  = new Timer(updateTitle, null, 1000, 1000);
            run    = true;
            thread = new Thread(loop);
            thread.IsBackground = true;
            thread.Start();
        }
        private void StartParseLog(string fileName)
        {
            run = false;
            parser.items.Clear();
            HitsDataGrid.Items.Refresh();
            runningTasks.Clear();
            PathList.Items.Refresh();

            inputStream = File.OpenText(fileName);

            Title = fileName;
            FileInfo f = new FileInfo(fileName);

            Title         += " " + f.Length / 1024 + "k";
            currentLogFile = fileName;
            currentLogSize = f.Length;
            currentTitle   = Title;
            string fileExt = Path.GetExtension(currentLogFile).ToLower();

            switch (fileExt)
            {
            case LogFileExtension.ASC:
                logParser = new VectorASCParser();
                break;

            case LogFileExtension.CSV:
                logParser = new SavvyCSVParser();
                break;

            default:
                logParser = null;
                break;
            }

            //runningTasks.Clear();
            timer?.Dispose();
            timer = null;

            foreach (var v in parser.items.Values)
            {
                if (v.Points == null)
                {
                    v.Points = new ConcurrentStack <CustomDataPoint>();
                }
                else
                {
                    v.Points.Clear();
                }
            }

            if (thread != null)
            {
                thread.Abort();
            }
            //thread.Abort(); to abort currently loading Trace
            //thread.Join(); to keep currently loading Trace and create new one

            timer  = new Timer(updateTitle, null, 1000, 1000);
            run    = true;
            thread = new Thread(loop);
            thread.IsBackground = true;
            thread.Start();
        }