Skip to main content

CRR0041 - Use Task.Run instead of Task.Factory.StartNew

This analyzer detects Task.Factory.StartNew thread execution statements that can be unsafe.

Task.Factory.StartNew(() => { DemoMethodSync(); });

To fix the issue, use the Task.Run method instead of Task.Factory.StartNew.

Task.Run(() => { DemoMethodSync(); });

For information on why you need to use Task.Run instead of Task.Factory.StartNew, see the following blog post: Task.Run vs Task.Factory.StartNew.