c# - Text Writer is already closed in a Delay Timer "Tick" Event -


I am trying to use a delay timer on a Windows application. I want to avoid threads. As a sleep I want the control to be active during the delay. Now I have a button that starts the code on click It opens a section and writes the title line in the CSV. If I check a timer tick, if a check box is checked, the timer will stop, but otherwise it writes a new line. After that, the timer has started. The writer is not closed until the execution of the timer. So, something like this,

  file stream midda = file. OpenRight ("myfile.csv"); TextWriter myWriter = new streamer (Meridian); MyWriter.Write ("headline, go, here \ n"); Int x = 0; DelayTimer.Tick + = Delegate {if (checkbox.Checked) {delayTimer.Stop (); } MyWriter.Write (x + "luggage \ n"); X ++; }; DelayTimer.Start (); MyWriter.Close ();  

However, whenever I try to execute, after pressing the button it is freeze and the Visual Studio informs me that the streamer is off. I'm not sure exactly how to fix it, as I thought the code would execute the timer before moving ahead, until I understand how this timer performs.

You have to be careful that after the Dell starts you turn off the stream, If the stream turns off, then the stream is closed

Pretend my bad English when trying to close the stream inside an anonymous representative. I hope I help you


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -