Timer stop after one execute.
Timer stop after one execute.
09 Feb 2023, 12:44
Why Timer stop after adding this code :
System.IO.File.WriteAllText(filePath,string.Empty);
or this line of code :
string[] lines = System.IO.File.ReadAllLines(filePath);
======================================================
StreamWriter _fileWriter;
string filee1 = "xauusdt301.txt";
[Parameter(DefaultValue = "Hello world!")]
public string Message { get; set; }
protected override void OnStart()
{
Timer.Start(TimeSpan.FromSeconds(10));
}
protected override void OnTimer()
{
Print(10);
var desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
string filePath = Path.Combine(desktopFolder, filee1);
System.IO.File.WriteAllText(filePath,string.Empty);
string[] lines = System.IO.File.ReadAllLines(filePath);
_fileWriter.Close();
}