Timer stop after one execute.

Created at 09 Feb 2023, 12:44
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
NA

nasrmirzaiiee@gmail.com

Joined 14.03.2021

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();
       }


@nasrmirzaiiee@gmail.com