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 class SparkleHelpers {
|
||||||
|
|
||||||
public static bool ShowDebugInfo = true;
|
public static bool ShowDebugInfo = true;
|
||||||
|
private static object debug_lock = new object ();
|
||||||
|
|
||||||
// Show debug info if needed
|
// Show debug info if needed
|
||||||
public static void DebugInfo (string type, string message)
|
public static void DebugInfo (string type, string message)
|
||||||
|
@ -39,10 +39,12 @@ namespace SparkleLib {
|
||||||
if (SparkleConfig.DefaultConfig.DebugMode)
|
if (SparkleConfig.DefaultConfig.DebugMode)
|
||||||
Console.WriteLine (line);
|
Console.WriteLine (line);
|
||||||
|
|
||||||
File.AppendAllText (
|
lock (debug_lock) {
|
||||||
SparkleConfig.DefaultConfig.LogFilePath,
|
File.AppendAllText (
|
||||||
line + Environment.NewLine
|
SparkleConfig.DefaultConfig.LogFilePath,
|
||||||
);
|
line + Environment.NewLine
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue