protected override void ThreadFunction() { isRunning = true; // Do your threaded task. DON'T use the Unity API here while (isRunning) { while (loggerQueue.logQueue.Count > 0) { log(loggerQueue.GetFromLogQueue()); } } close(); }
IEnumerator LogWriter() { isRunning = true; logfile = new StreamWriter(fileName, true, Encoding.ASCII, 0x10000); UnityEngine.Debug.Log("running logwriter coroutine writing at " + fileName); while (isRunning) { while (myLoggerQueue.logQueue.Count > 0) { string msg = myLoggerQueue.GetFromLogQueue(); // UnityEngine.Debug.Log ("writing: " + msg); logfile.WriteLine(msg); yield return(0); } yield return(0); } UnityEngine.Debug.Log("closing this"); yield return(null); }