I am trying to implement code to support authentication using an external library. The authentication result is returned asynchronously using a Java listener. Using JNI, I pass an interface implementing IAuthResultHandler that exposes OnAuthenticated and OnAuthenticationError.
So, basically, when I call the authentication method, I pass the handler. The OnAuthenticated gets called asynchronously when the result is known.
My problem: the call to OnAuthenticated is done on the main thread instead of the thread where the object was created. A Java programmer told me this was the norm in Java. I was trying to await the call to the callback, but the tests in NUnitLite are also executed on the main thread, which causes a deadlock.
Any idea how I could get around this?