Sure, no problem. I've set breakpoints at
- Form1_Load on "phid = new Spatial();"
- phid_Attach on "phid.DataRate = phid.DataRateMax;"
- drawThreadFunc on "Math3D.RotatePoints(p.rotMatrix, p.vertexBuffer, p.originalVertices);"
- phid_SpatialData on "Pipeline.fillpen = Color.White;"
Surprisingly, the crash now seems to happen in drawThreadFunc on "if (positionRadio.Checked)"
However, if I comment-out the entire try/catch block and add "Thread.Sleep(10);" in the while-loop, the crash still occurs.
After some more single-stepping, I find that it almost always happens after the phid_Attach function ends (and returns control to the calling function). Maybe you can check to code that calls the Attach event-handler?
I just uncommented the contents of the while-loop in drawThreadFunc, and now the crash happens when I F10 over the RotatePoints function. However, when I look at the threads list, the 'active' arrow is not on the thread that is running drawThreadFunc, but on an unnamed thread that is not reporting a location.
That would explain why it happens on different locations in the sample-code: the time of the error in the other thread (which I cannot see) just happens to coincide with some function or other in the main thread. (which I can see).
My guess would therefore be that the error is not in the sample itself, but in the code that calls functions in the sample, and which is in a different thread than the main process, and also not in the drawing thread (since then we would have seen the location of the exception).
What's good to know is that the breakpoint on phid_SpatialData has not been triggered when it happens, so it appears that it happens really early in the process of receiving data from the sensor..
Hope this helps!