When I use c #, I wrote a class to save logs. The general practice is:
[Csharp]
// Write logs to file
Public class LogInfo
{
Static public LogInfo getInstance (){
If (pLogInfo = null)
PLogInfo = new LogInfo ();
Return pLogInfo;
}
Private LogInfo ()
{
ILine = 0;
LogFile = new StreamWriter (@ "Gobang. log", true );
LogFile. AutoFlush = true;
}
~ LogInfo ()
{
// Why this operation can cause something that Windows regards as a problem?
LogFile. Close ();
}
Public void WriteLog (string strInfo)
{
LogFile. WriteLine (iLine + "" + strInfo );
ILine ++;
}
Public void WriteLogFlush (string strInfo)
{
WriteLog (strInfo );
}
Private static int iLine;
Private StreamWriter logFile;
Static private LogInfo pLogInfo;
}
Because the StreamWriter operation is disabled during the analysis, every time the windows form program is closed, windows prompts that the program is being closed, and calls "find a solution to the problem... "processing mechanism. Does anyone know why?