helpers: only allow one thread to write to the log at a time. Fixes some crashes
This commit is contained in:
parent
649fab3826
commit
dc0167a300
|
@ -23,7 +23,7 @@ namespace SparkleLib {
|
|||
public static class SparkleHelpers {
|
||||
|
||||
public static bool ShowDebugInfo = true;
|
||||
|
||||
private static object debug_lock = new object ();
|
||||
|
||||
// Show debug info if needed
|
||||
public static void DebugInfo (string type, string message)
|
||||
|
@ -39,10 +39,12 @@ namespace SparkleLib {
|
|||
if (SparkleConfig.DefaultConfig.DebugMode)
|
||||
Console.WriteLine (line);
|
||||
|
||||
File.AppendAllText (
|
||||
SparkleConfig.DefaultConfig.LogFilePath,
|
||||
line + Environment.NewLine
|
||||
);
|
||||
lock (debug_lock) {
|
||||
File.AppendAllText (
|
||||
SparkleConfig.DefaultConfig.LogFilePath,
|
||||
line + Environment.NewLine
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue