private void ClearTimer_Elapsed(object sender, ElapsedEventArgs e) { try { Dispatcher.Invoke(() => { if (ClearText < Cos.Text.Length) { Cos.Text = Cos.Text.Substring(ClearText); Cos.ScrollToEnd(); } ClearText = Cos.Text.Length; }); try { logWriter.Close(); logWriter.Dispose(); } catch (Exception) { } logWriter = File.AppendText(GetPathF(config["LogAPI"].Value <string>("Path"))); } catch (Exception) { } }