Is there any way to reset thread from debugger to VS

I am using VS 2010 and working with a lot of threads in C # in my current project. I have written several thread dump utilities for recording certain types of streams for debugging purposes, but I seem to constantly stumble on the times when I am debugging, and I need to look into the stream from which I am debugging, but I did not put my dump calls there. It seems like I could dump the stream somehow simply using VS or maybe tell it to call one of my dump methods in the stream in the debugger. Is there any way to do this?

The streams I'm working with have text describing a blob of data, and then blob bytes, so finding a description is useful. My dump methods usually just dump this information and then drop drops.

+5
source share
4 answers

Perhaps you could write a document document? MSDN explains how here: http://msdn.microsoft.com/en-us/library/e2zc529c.aspx

+4
source

Enter this in the Immediate window:

System.Diagnostics.Debug.WriteLine((new System.IO.StreamReader(stream)).ReadToEnd());
+9
source

:

MikeDsDumpFxn(whateverStreamIsActiveInThisContext)

, .

+1

, , immediate window:

var lastPos = stream.Position;
stream.Seek(0, SeekOrigin.Begin)
File.WriteAllBytes("filepath.bin", new BinaryReader(stream).ReadBytes((int)stream.Length))
stream.Seek(lastPos, SeekOrigin.Begin)

, , ( ).

Length, , :

var lastPos = stream.Position;    
var ms = new MemoryStream();
stream.Seek(0, SeekOrigin.Begin)
stream.CopyTo(ms)
File.WriteAllBytes("filepath.bin", ms.ToArray())
stream.Seek(lastPos, SeekOrigin.Begin)
0

All Articles