I have a legacy code library that provides the following method signature
void DoWork(IEnumerable<IMessage> message,
Action<IEnumerable<IMessage>, Exception> onErrorCallBack,
Action<IEnumerable<IMessage>> onCompletionCallBack);
When I call this method in my code, I am unable to wait for the onErrorCallBack and starts executing the next line of code. Is there a way to wait for the callbacks to arrive and then proceed to the next line? This is getting more worst if i fire this method inside a parallel for loop. The loop continues without waiting for the callback and results in many calls bogging down my system resources. Any respite?