Пример #1
0
        private void LoadLog(string path, LoadProgressUpdate progressCallback)
        {
            // Caller must check that path is a valid file location.
            frames.Clear();

            try
            {
                progressCallback(0d);

                using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
                {
                    DataStream dataStream = new DataStream(stream);

                    while (stream.Position < stream.Length)
                    {
                        FrameResult result = FrameResult.Deserialize(dataStream);
                        frames.Add(result);

                        progressCallback((double)stream.Position / (double)stream.Length);
                    }
                }

                progressCallback(1d);
            }
            catch (Exception e)
            {
                MessageBox.Show(string.Format("Failed to load file {0} -> {1}", path, e.Message), "Profiler log viewer", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }