Smart Client freeze on Invoke

I have this method to draw overlay:

        void DrawOverlay(ImageViewerAddOn addOn, DateTime timestamp)
        {
            if (addOn == null)
                return;
 
            if (System.Windows.Forms.Application.OpenForms.Count > 0)
            {
                if (System.Windows.Forms.Application.OpenForms[0].InvokeRequired)
                {
                    System.Windows.Forms.Application.OpenForms[0].Invoke(new Action(() => DrawOverlay(addOn, timestamp)));
                }
                else
                {
                    ....
                }
    }

When I change the viewgroup or switch to playback, the client hangs on Invoke maybe 50% of the time. How can I prevent this?

                    System.Windows.Forms.Application.OpenForms[0].Invoke(new Action(() => DrawOverlay(addOn, timestamp)));

Please use this (optimized and safe) method:

-–

virtual void VideoOS.Platform.ClientControl.CallOnUiThread ( Action actionToBeInvoked )

inlinevirtual

--

Use this method to have a method executed on the UI thread.

The below line will call the MuFillTextBox method on the UI thread.

ClientControl.Instance.CallOnUiThread( () => MyFillTextBox(“fill this text”) );

private void MyFillTextBox(String s)

{

_myTextBox.Text = s;

}

--

Parameters

actionToBeInvoked

-–

Ref. https://doc.developer.milestonesys.com/html/index.html?base=miphelp/class_video_o_s_1_1_platform_1_1_client_control.html&tree=tree_search.html?search=callonui