0

For some weeks now I've been working on an App that allows users to create a Website base, based on teir settings, now i only have the Launch button (export button) left to do, and what it is supposed to do, is to open a window with a Go button (wich is already working and stuff). The thing is that I want the user to know what is happening right now (example: Connecting to ...) similar to an installer, so I want the elements added line by line but with a delay

The Problem: I can't add a delay to the writing process, yes the waiting process starts, but the text is just jammed into the ScrollView all at once, however, I did some test with Trace.WriteLine and it worked normally in the console(had a counter count up) but once again, the counter reached its end and the entire input was once again smashed into the box. I tried: Thread.Sleep, Task.Delay(), Task.Delay().Wait(), and await Task.Delay(), but nothing seemed to work, it doesn't matter if I output the text into a TextBox, a ListView, a ScrollViewer or even a Label The Code:

The Function to add the Log input

        void AddLog(string msg)
        {
            Wait();
            Logbox.Content = Logbox.Content + $"\n{msg}";
            Logbox.ScrollToEnd();
        }

The Wait Function (Please note that this only exists because I thought that maybe the whole function needs to finish for it to update, so I tried to put the delay into a different function):

        int n = 0;
        void Wait()
        {
            Trace.WriteLine(n);
            n++;
            Thread.Sleep(1000);
        }

The Logging system works as following: AddLog("your log message"); I tried googling the problem but I only found unrelated answers to my problem, so I decided to ask on here myself. Thanks for reading.

0 Answers0