My app does a lot of background tasks, and for each such action, I created a new thread for each action
Thread StreamResponse = new Thread(() =>
{
DB.ToDb(flag);
});
StreamResponse.Start();
These actions take place thousands per minute. Noticed that the app starts eating RAM. That's normal, because the application creates thousands of threads and not closing them.
From here there is a question, how do I make it so that these actions were in a separate thread. For example, I create a thread in a separate class and in this thread commit acts.
Or otherwise can? The task that the thread was made and after the completion of the action is automatically closed. But perhaps more correctly just all these steps to do in another thread. What do you think? How to make?
May be using Dispatcher.BeginInvoke
?