I have a class member variable _stream which is a FileStream. This variable gets initialized in the constructor and needs to stick around until I'm done with the class. I have another class that raises an event every time something needs to be written to the file. In my main class I have an event handler that performs the actual writing. I tried the following code as in this question:
void MyEventHandler(string message)
{
using (_stream)
using (StreamWriter s = new StreamWriter(_stream))
s.WriteLine(message);
}
But this doesn't work because using disposes of my FileStream before I'm done with it. What should I be doing instead?