Beispiel #1
0
        public SaveState(SaveInfo info, Exception ex, AsyncOperation asyncOp)
        {
            m_saveInfo = info;

            m_exception      = ex;
            m_asyncOperation = asyncOp;
        }
Beispiel #2
0
        public virtual void SaveAsync(Dump dump, DumpFormat format, Stream stream, object taskId)
        {
            SaveInfo info = new SaveInfo(dump, format, stream);

            AsyncOperation asyncOp = CreateOperation(taskId);

            m_workerDelegate = new WorkerEventHandler(SaveWorker);
            m_workerDelegate.BeginInvoke(info, asyncOp, m_completionMethodDelegate, null, null);
        }
Beispiel #3
0
        public virtual void SaveAsync(Dump dump, DumpFormat format, Stream stream, object taskId)
        {
            SaveInfo info = new SaveInfo(dump, format, stream);

            AsyncOperation asyncOp = CreateOperation(taskId);

            m_workerDelegate = new WorkerEventHandler(SaveWorker);
            m_workerDelegate.BeginInvoke(info, asyncOp, m_completionMethodDelegate, null, null);
        }
Beispiel #4
0
        private void DoSave(SaveInfo info, AsyncOperation asyncOp)
        {
            BinaryWriter binWriter = new BinaryWriter(info.m_stream, Encoding.ASCII);

            char[] magic        = "oSpy".ToCharArray();
            uint   version      = 2;
            uint   isCompressed = (info.m_format == DumpFormat.Compressed) ? 1U : 0U;
            uint   numEvents    = (uint)info.m_dump.Events.Count;

            binWriter.Write(magic);
            binWriter.Write(version);
            binWriter.Write(isCompressed);
            binWriter.Write(numEvents);
            binWriter.Flush();
            binWriter = null;

            Stream stream = info.m_stream;

            if (info.m_format == DumpFormat.Compressed)
            {
                stream = new BZip2OutputStream(stream);
            }
            XmlTextWriter xmlWriter = new XmlTextWriter(stream, Encoding.UTF8);

            xmlWriter.WriteStartDocument(true);
            xmlWriter.WriteStartElement("events");

            int eventCount = 0;

            foreach (Event ev in info.m_dump.Events.Values)
            {
                if (asyncOp != null)
                {
                    int pctComplete            = (int)(((float)(eventCount + 1) / (float)numEvents) * 100.0f);
                    ProgressChangedEventArgs e = new ProgressChangedEventArgs(pctComplete, asyncOp.UserSuppliedState);
                    asyncOp.Post(m_onProgressReportDelegate, e);
                }

                xmlWriter.WriteRaw(ev.RawData);

                eventCount++;
            }

            xmlWriter.WriteEndElement();
            xmlWriter.Flush();
            stream.Close();
        }
Beispiel #5
0
        private void SaveWorker(SaveInfo info, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate)
        {
            Exception exception = null;

            try
            {
                DoSave(info, asyncOp);
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            SaveState saveState = new SaveState(info, exception, asyncOp);

            try
            {
                completionMethodDelegate(saveState);
            }
            catch (InvalidOperationException)
            {
            }
        }
Beispiel #6
0
        public virtual void Save(Dump dump, DumpFormat format, Stream stream)
        {
            SaveInfo info = new SaveInfo(dump, format, stream);

            DoSave(info, null);
        }
Beispiel #7
0
 internal SaveCompletedEventArgs(SaveInfo info, Exception e, bool cancelled, object state)
     : base(e, cancelled, state)
 {
     m_saveInfo = info;
 }
Beispiel #8
0
        private void SaveWorker(SaveInfo info, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate)
        {
            Exception exception = null;

            try
            {
                DoSave(info, asyncOp);
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            SaveState saveState = new SaveState(info, exception, asyncOp);

            try
            {
                completionMethodDelegate(saveState);
            }
            catch (InvalidOperationException)
            {
            }
        }
Beispiel #9
0
 public virtual void Save(Dump dump, DumpFormat format, Stream stream)
 {
     SaveInfo info = new SaveInfo(dump, format, stream);
     DoSave(info, null);
 }
Beispiel #10
0
 internal SaveCompletedEventArgs(SaveInfo info, Exception e, bool cancelled, object state)
     : base(e, cancelled, state)
 {
     m_saveInfo = info;
 }
Beispiel #11
0
        public SaveState(SaveInfo info, Exception ex, AsyncOperation asyncOp)
        {
            m_saveInfo = info;

            m_exception = ex;
            m_asyncOperation = asyncOp;
        }
Beispiel #12
0
        private void DoSave(SaveInfo info, AsyncOperation asyncOp)
        {
            BinaryWriter binWriter = new BinaryWriter(info.m_stream, Encoding.ASCII);

            char[] magic = "oSpy".ToCharArray();
            uint version = 2;
            uint isCompressed = (info.m_format == DumpFormat.Compressed) ? 1U : 0U;
            uint numEvents = (uint)info.m_dump.Events.Count;

            binWriter.Write(magic);
            binWriter.Write(version);
            binWriter.Write(isCompressed);
            binWriter.Write(numEvents);
            binWriter.Flush();
            binWriter = null;

            Stream stream = info.m_stream;
            if (info.m_format == DumpFormat.Compressed)
                stream = new BZip2OutputStream(stream);
            XmlTextWriter xmlWriter = new XmlTextWriter(stream, Encoding.UTF8);
            xmlWriter.WriteStartDocument(true);
            xmlWriter.WriteStartElement("events");

            int eventCount = 0;
            foreach (Event ev in info.m_dump.Events.Values)
            {
                if (asyncOp != null)
                {
                    int pctComplete = (int)(((float)(eventCount + 1) / (float)numEvents) * 100.0f);
                    ProgressChangedEventArgs e = new ProgressChangedEventArgs(pctComplete, asyncOp.UserSuppliedState);
                    asyncOp.Post(m_onProgressReportDelegate, e);
                }

                xmlWriter.WriteRaw(ev.RawData);

                eventCount++;
            }

            xmlWriter.WriteEndElement();
            xmlWriter.Flush();
            stream.Close();
        }