Putting it in do{}while(_boxMesh == null) causes an endless loop. This is the first time I’ve seen null returned from this method, and I’d like to know where it can fail and why. I mean, what’s the reason that the internal method returns IntPtr.Zero obviously.
Ahh … maxCorner typo - y is still minus, so box is flat. Though it still should return mesh (?) flat or just Mesh with one face (?). Although it would still be nice to know what edge cases are discarded and when null is expected.
I think most if not all C# APIs in Rhino will return null on an error, and when it comes to geometry there are many possible errors. I’d recommend always checking any method that outputs a class for null.