I am building an app within an application called Rhino where it has a button to call this method.
public void AttachPopupToViewportWindow()
{
_originalBound = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.Bounds;
try
{
_formWindow = new SW.Win32Window(NativeHandle);
General._viewportWindow.AddControl(_formWindow);
}
catch (System.ComponentModel.Win32Exception ex)
{
}
}
When the method is called repeatedly in a very short time, the NativeHandle
cannot be read anymore and it throws an Unhandled Exception.
The NativeHandle
represents a IntPtr
address to the WPF control.
I tried different ways of bypassing this exception. They all failed to work. Why hasn't the try-catch block catch the exception?