Unintended behavior of components with Viewport as a parameter

For the purpose of visualization in a specific Viewport, the Param_ModelStandardViewport class was added to the input of the component as follows, with Viewport as the parameter input.

int ivp = pManager.AddParameter(new Param_ModelStandardViewport(),
    "Viewport", "Viewport", "Viewport Input", GH_ParamAccess.list);

The component can now have a Viewport input as intended, but if I set a Viewport to this Input, the component’s SolveInstance() is called whenever that Viewport is updated, for example, by a mouse viewpoint operation. Is there any way to prevent the SolveInstance() call due to Viewport updates?

I’m not sure, but you could probably wire up your component to one of the exposed events of the param object (would have to declare the param as a private field, and add that as an argument).

Then on event change set a private true/false field flag that you can check in solve instance to either solve or not solve.

Thank you for your reply. Specifically, what you proposed is to set an event and switch the flag as shown below?

private bool is_viewport_param_raise_expire_solution = false;
private Param_ModelStandardViewport m_viewport_param = new Param_ModelStandardViewport();
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
    pManager.AddParameter(m_viewport_param,
        "Viewport", "Viewport", "Viewport Input", GH_ParamAccess.list);

    m_viewport_param.SolutionExpired += (s, e) => {
        RhinoApp.WriteLine("Solution Expire Event");
        is_viewport_param_raise_expire_solution = true;
        // -> Check in SolveInstance?
    };

    this.SolutionExpired += (s, e) =>
    {
        RhinoApp.WriteLine("Solution Expired Event(Component)");
        // -> How do I know when an event occurs due to a viewport parameter?
    };
}

The SolutionExpired event for Param_ModelStandardViewport does not seem to occur depending on the Viewport update in question. (I have also checked the other events and they do not fire.) Next, the component event is fired, but I don’t know how to determine if the SolutionExpired event was fired due to an update of the target viewport here.

I would be very grateful for any advice or suggestions on my lack of understanding.