The stream records my GUI

I have a stream that removes data from a queue and writes it to another STDIN application. I use Stream, but with .Write and even .BeginWrite, when I send 1 MB of fragments to the second application, my GUI becomes ~ 1 sec behind. What for? My callbacks look something like this:

    void Progress(object sender, ProgressArgs e) {
        if (this.InvokeRequired) {
            this.BeginInvoke(new MethodInvoker(delegate() { Progress(sender, e); }));
            return;
        }

        progressBar1.Value = (int) e.PercentDone;
    }
+3
source share
1 answer

I would say you call these callbacks too often to clutter your message queue with messages BeginInvoke. Try to save the last percentage value received and BeginInvokeonly call when the new one is different from the last.

0
source

Source: https://habr.com/ru/post/1745631/


All Articles