BackgroundWorker component in services

I know that BackgroundWorker should not be used in Windows Services, but does anyone have a good online link explaining why?

+5
source share
3 answers

BackgroundWorker relies on the current SynchronizationContext to work. It is really designed and developed specifically for working with user interface code.

As a rule, it is better to serve your threads, since there are no problems with the synchronization of the user interface. Using the streaming API (or the .NET 4 Task API) is a much better option here.

+7
source

, BGW , . ProgressChanged RunWorkerCompleted . - . , . . "", , .

. , , , . , , . 99% , , Windows - . , , , - . , . .

, Winforms Control.Begin/Invoke WPF Dispatcher.Begin/Invoke . , , . WindowsFormsSynchronizationContext DispatcherSynchronizationContext - , . Winforms WPF SynchronizationContext.Current . , , BGW . . , , .

, , , . . threadpool . , , BGW . . DoWork . , , DoWork, threadpool.

, , .

+2

BackgroundWorker Windows - . SynchronizationContext , , .

+1

All Articles