Remove observer from ObservableFinished
-
Hi everyone,
I am creating a job that does some potentially long-ish computation in a queue in the background. To that job I added an finish observer like this:
_job.ObservableFinished().AddObserver(ConcurrentGeneratorObjectData::WatchGeneratorFinished) iferr_ignore();
The
_job
variable in this example is of typemaxon::JobResultRef<BaseObject*>
.The
WatchGeneratorFinished()
observer function just fires anEventAdd()
when the job finishes, which is usually what I want. There are, however, certain events in the scene that I am listening to which indicate that this is not the behavior I want (e.g. an editor render being kicked off) in which case I would like to remove the observer (to potentially add it back again later). I did find a functionObservableBaseInterface::RemoveObserver()
, which appears to do what I want, but I am having a hard time finding out how to use it. TheObservableFinishedBase
object that is returned from JobResultRef<>::ObservableFinished()` function I am using does not seem to implement it. Is there a way for me to do this?Any pointers very much appreciated!
-
hello,
a simplified snippet on how you are implementing your job would be much appreciate.
Cheers,
Manuel -
hello,
I've asked the dev and it's not supported.
Be aware that you could be in the position where you are trying to remove the observer but it has already been called.The suggestion is to create a local bool variable to know if you want the observer to be executed.
Cheers,
Manuel -
i'll set that thread as solved.