79610063

Date: 2025-05-07 08:11:34
Score: 0.5
Natty:
Report link

It looks like I’ve found a solution. Task.Run only queues the given work on the thread pool — it doesn’t start a new thread. So when I do something like this:

        private async Task ReadFromHddAsync(string path)
        {

            await Task.Factory.StartNew(() =>
            {
                ReadFromHdd(path);           
            }, TaskCreationOptions.LongRunning);
        }
    
        private async Task SaveToHddAsync(string path)
        {
            await Task.Factory.StartNew(() =>
            {
                SaveToHdd(path);
            }, TaskCreationOptions.LongRunning);
        }

Then ManualResetEventSlim will not block another task.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Stanko Milosev