Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Remove observer from ObservableFinished

    Cinema 4D SDK
    2
    4
    592
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tdapper
      last edited by

      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 _jobvariable in this example is of type maxon::JobResultRef<BaseObject*>.

      The WatchGeneratorFinished() observer function just fires an EventAdd() 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 function ObservableBaseInterface::RemoveObserver(), which appears to do what I want, but I am having a hard time finding out how to use it. The ObservableFinishedBaseobject 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!

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        hello,

        a simplified snippet on how you are implementing your job would be much appreciate.

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • ManuelM
          Manuel
          last edited by

          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

          MAXON SDK Specialist

          MAXON Registered Developer

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by

            i'll set that thread as solved.

            MAXON SDK Specialist

            MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • First post
              Last post