C# Communication between threads

后端 未结 6 530
情话喂你
情话喂你 2021-01-11 22:34

I am using .NET 3.5 and am trying to wrap my head around a problem (not being a supreme threading expert bear with me).

I have a windows service which has a very int

6条回答
  •  耶瑟儿~
    2021-01-11 23:09

    The BackgroundWorker is a bit slower than using plain threads, but it has the option of supporting the CancelAsync method.
    Basically, BackgroundWorker is a wrapper around a worker thread with some extra options and events.

    The CancelAsync method only works when WorkerSupportsCancellation is set.
    When CancelAsync is called, CancellationPending is set.
    The worker thread should periodically check CancellationPending to see if needs to quit prematurely.

    --jeroen

提交回复
热议问题