I have a C# application using a C++ DLL. The C++ DLL is extremely simple. I can call one method, and it has a callback method. The callback method must finish before I can process the next item.
The problem is, I can only process one command at a time, but I want to process them as fast as possible.
Fake/simplified code interface for c++ DLL:
void AddNumbers(int a, int b, AddNumbersCallback callback);
Now lets try to use it:
void DoStuff()
{
if(MyCollection.HasStuff)
AddNumbers(MyCollection.First().a, MyCollection.First.b, StuffDone);
}
void StuffDone(int result)
{
//I wish I could process the next item here, but the callback isn't done!
//DoStuff();
}
The root of the problem is that I want to execute code after the callback is done.
My temporary solution was to queue an item in the threadpool, and wait 100ms. Typically, that will give the method time to "finish".
And "no", I can't change the DLL.