Runtime: Deprecate BackgroundWorker.RunWorkerAsync

Created on 9 Mar 2018  路  2Comments  路  Source: dotnet/runtime

For me, it is very misleading that BackgroundWorker.RunWorkerAsync uses the convention with suffix *Async but doesn't return a Task.

Please consider deprecating this method and come with a new methodname.
The same applies to CancelAsync

Fixing it would not be possible because it's a breaking change.

Or... deprecate BackgroundWorker completely and come with an (better) alternative.
For example one with async/await, cancellationtoken support etc. Would that be Task.Factory.StartNew or Task.Run?

area-System.ComponentModel enhancement

Most helpful comment

deprecate BackgroundWorker completely and come with an (better) alternative.
For example one with async/await, cancellationtoken support etc. Would that be Task.Factory.StartNew or Task.Run?

According to Stephen Cleary, yes, Task.Run is the replacement for BackgroundWorker, see his series of blog posts where he compares the two.

Assuming the team agrees with that, I think it would make sense to make BackgroundWorker deprecated by adding it to the Platform Compatibility Analyzer.

All 2 comments

deprecate BackgroundWorker completely and come with an (better) alternative.
For example one with async/await, cancellationtoken support etc. Would that be Task.Factory.StartNew or Task.Run?

According to Stephen Cleary, yes, Task.Run is the replacement for BackgroundWorker, see his series of blog posts where he compares the two.

Assuming the team agrees with that, I think it would make sense to make BackgroundWorker deprecated by adding it to the Platform Compatibility Analyzer.

Is [Deprecated] still used for a build-time notification, for those who may bypass the analyzer?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

v0l picture v0l  路  3Comments

bencz picture bencz  路  3Comments

aggieben picture aggieben  路  3Comments

matty-hall picture matty-hall  路  3Comments

EgorBo picture EgorBo  路  3Comments