Ejemplo n.º 1
0
        private void StartWatchingFile(string file)
        {
            new Thread(() =>
            {
                bool isWatching = true;
                while (isWatching)
                {
                    ReverseTextReader reader = new ReverseTextReader(_clientFileStream, Encoding.UTF8);
                    string line = reader.ReadLine(); //last line always a new line
                    line        = reader.ReadLine();

                    Regex pattern = new Regex($"{_characterName}.*is now level (\\d*)");
                    Match match   = pattern.Match(line);
                    if (match.Success)
                    {
                        string level = match.Groups[1].Value;
                        Application.Current.Dispatcher.Invoke(new Action(() => { characterLevel.Text = level; }));
                    }
                    Thread.Sleep(1000);
                }
            })
            {
                IsBackground = true
            }.Start();
        }
Ejemplo n.º 2
0
        // Define the event handlers.
        private void OnClientTxtChanged(object source, FileSystemEventArgs e)
        {
            // Specify what is done when a file is changed, created, or deleted.
            //Console.WriteLine("File: " + e.FullPath + " " + e.ChangeType);
            ReverseTextReader reader = new ReverseTextReader(_clientFileStream, Encoding.UTF8);
            //while (!reader.EndOfStream)
            //{
            //read last line
            string line = reader.ReadLine(); //last line always a new line

            line = reader.ReadLine();

            Regex pattern = new Regex($"{_characterName}.*is now level (\\d*)");
            Match match   = pattern.Match(line);

            if (match.Success)
            {
                string level = match.Groups[1].Value;
                Application.Current.Dispatcher.Invoke(new Action(() => { characterLevel.Text = level; }));
            }

            //inStream.Close();
            // }
        }