Use invariant culture in debug timer

This commit is contained in:
Jaex 2019-10-21 10:07:06 +03:00
parent 100f3cc447
commit 705901703d

View file

@ -25,12 +25,13 @@ You should have received a copy of the GNU General Public License
using System;
using System.Diagnostics;
using System.Globalization;
namespace ShareX.HelpersLib
{
public class DebugTimer : IDisposable
{
public string Text { get; private set; }
public string Text { get; set; }
private Stopwatch timer;
@ -40,7 +41,7 @@ public DebugTimer(string text = null)
timer = Stopwatch.StartNew();
}
private void Write(string text, string timeText)
private void Write(string time, string text = null)
{
if (string.IsNullOrEmpty(text))
{
@ -49,20 +50,22 @@ private void Write(string text, string timeText)
if (!string.IsNullOrEmpty(text))
{
timeText = text + ": " + timeText;
Debug.WriteLine(text + ": " + time);
}
else
{
Debug.WriteLine(time);
}
Debug.WriteLine(timeText);
}
public void WriteElapsedSeconds(string text = null)
{
Write(text, timer.Elapsed.TotalSeconds.ToString("0.000") + " seconds.");
}
public void WriteElapsedMilliseconds(string text = null)
{
Write(text, timer.Elapsed.TotalMilliseconds + " milliseconds.");
Write(timer.Elapsed.TotalMilliseconds.ToString("0.000", CultureInfo.InvariantCulture) + " milliseconds.", text);
}
public void WriteElapsedSeconds(string text = null)
{
Write(timer.Elapsed.TotalSeconds.ToString("0.000", CultureInfo.InvariantCulture) + " seconds.", text);
}
public void Dispose()