In the project, do a text log function
In order not to affect the page response speed, so the use of multi-threading, at the time of testing, the risk of file writing is often unsuccessful, after some setbacks,
Discover th. IsBackground = true; a background thread is not a child of the main thread, which is represented as a child thread of the main thread, and the child threads are closed together if the main thread is closed.
After commenting out the code, the query is normal.
Public voidAsync_writelog_desc (ObjectLOGOBJCT,stringOldobject,ObjectnewObject) {Thread th=NewThread (NewParameterizedthreadstart (THEADINVOK_WRITELOG_DESC)); Logentity LG=Newlogentity (); LG.LOGOBJCT=logobjct; Lg.oldobject=Oldobject; Lg.newobject=NewObject; //th. IsBackground = true; background thread is not a child thread of the main threadth. Start (LG); }
C # multithreaded write file, often write unsuccessful