I have a WPF application that uses several background threads to precompile LINQ queries and suppress some values ββthat will be needed later. TPL is used to run these tasks by:
var newTask = new Task(taskAction, myCancelToken, TaskCreationOptions.LongRunning); newTask.Start();
This works, tasks are distributed across several processor cores, etc. However, these threads cause a high processor load, which is felt in the user interface, which tends to stumble or even freeze if the threads are not finished.
So, what could be a smart way to smooth the user interface. While researching, I found that he should not give threads special priorities. Others mean that frequent use of Thread.Sleep () is a way that seems a bit exhausted and hacked to me.
Are there any additional ways that I don't know about? Are there real flaws in a priori threads (which is not possible with TPL directly, afaik)?
Thanks in advance!
source share