I have a strategy that is used to output some values into a file. I have clean up in State.Terminated for StreamWriter like this:
private StreamWriter sw;
else if(State == State.Terminated)
{
// Necessary to call in order to clean up resources used by the StreamWriter object
if (sw != null)
{
sw.Close();
sw.Dispose();
sw = null;
}
}
End everything work fine in backtest mode but when I try optimization I got error: The process cannot access the file .... because it is being used by another process.
I need this to output optimization variables and my own calculations.
Comment