Reactive Extensions OnNext thread-safety

前端 未结 3 978
日久生厌
日久生厌 2021-01-01 19:08

With the Rx Subject, is it thread-safe to call OnNext() from multiple threads?

So the sequence can be generated from multiple sources.

3条回答
  •  死守一世寂寞
    2021-01-01 19:44

    Calling someSubject.OnNext() is as thread-safe as someList.Add() - you can call it from > 1 thread, but not concurrently. Wrap your OnNext in a lock statement and it'll be safe.

提交回复
热议问题