Ok, I got a chance to sit down and inspect your code. You are getting an exception, but it is not a DaqException. The code as written will cause an access violation. In ThunkClass::Thunk, you have
CDiomxHandler* pThis = (CDiomxHandler*)AfxGetMainWnd ();
pThis->OnDataReady (ar);
CDiomxHandler is not a CWnd-derived class and is not your main window. The c-style cast succeeds as a dangerous reinterpret_cast (you should have gotten a warning C4669) and executes OnDataReady with an invalid this pointer. You see the first dialog box in OnDataReady because you have not yet attempted to access any members on the invalid this pointer. When you attempt to get the reader pointer to call EndReadS
ingleSampleMultiLine, you get an access violation.
If you rewrite the code to pass the pointer to your CDiomxHandler as the "AsyncState" when you begin your asynchronous read, you can retrieve it from the IAsyncResult and get your CDiomxHandler pointer. (AsyncState exists for precisely this purpose). I've attached a simplified version of your program that does this. This example uses a small amount of advanced .NET interop code to package the CDaqHandler pointer into a managed Object* and unpackage it in the thunk. This is just one way to do it, there certainly are other ways.
Good luck!
Tony H
Measurement Studio