I have a console app that sometimes does NOT exit when I issue the following 2 lines:
File.AppendAllText(@"\\bbd\FLog", "Halting: " + DateTime.UtcNow.ToString("dd-MM-yyyy HH:mm:ss") + "\n");
System.Environment.Exit(0);
The halting message IS written to disk, but the application is still alive in taskmanager.
The application does use a threading timer:
GetRecordsTimer = new System.Threading.Timer(new TimerCallback(GetRecordsCallBack), null, 60000, 0);
That is declared as:
public static System.Threading.Timer GetRecordsTimer;
BUT my understanding of Environment.Exit(0) is that is kills everything (all threads) and then exits.
Note: not only is the application still alive, but my log file FLog appears to be in use...
Could it be that AppendAllText is somehow not finished if I exit immediately afterwards?