You can post code using code tags.
First thing to note is that this doesn’t need to be exceptional behaviour at all. You can let it finish normally and notify the caller in any desired way about the failure / timeout.
The above is not an actual solution, but rather just a recommendation, next thing you might wanna try is whether it works in general, i.e. write a function that throws and catches the exception. Call it from C#, see what happens.
Also make sure you’re at least getting a BestMove in any case or add some defensive logic to avoid access of BestMove if it might ever be a nullptr, and that everything is set up correctly. It’s simply too easy to crash an application in C++.
You might also be able to debug or add some logging so that you know what’s going on and can figure out where it stops working, and possibly why…
You could also upload a minimal version to reproduce the behaviour.