Are there any cases when it's preferable to use a plain old Thread object instead of one of the newer constructs?

前端 未结 10 2119
挽巷
挽巷 2021-01-30 01:45

I see a lot of people in blog posts and here on SO either avoiding or advising against the usage of the Thread class in recent versions of C# (and I mean of course

10条回答
  •  情话喂你
    2021-01-30 02:45

    The Thread class is not obsolete, it is still useful in special circumstances.

    Where I work we wrote a 'background processor' as part of a content management system: a Windows service that monitors directories, e-mail addresses and RSS feeds, and every time something new shows up execute a task on it - typically to import the data.

    Attempts to use the thread pool for this did not work: it tries to execute too much stuff at the same time and trash the disks, so we implemented our own polling and execution system using directly the Thread class.

提交回复
热议问题