Despite all efforts of trying to capture all console out messages, I am experiencing a strange issue in which I have two console apps:
The issue is that if I directly launch "DeviceController.exe" then I get some useful console output messages from the PInvoked DLL along with my intended messages from the app. If instead I start it through "ConsoleWrapper.exe" then a very strange effect occurs: the messages from PInvoke DLL are somehow delayed.
By this I mean that they seem to get lost but in reality they are all flushed at once when the process of "DriverController.exe" finishes or when I order a (kernel32).FreeLibrary() of the DLL to the "DeviceController.exe". It is as if the PInvoked DLL has a different console buffer from the one on my C# apps.
Does someone has an idea of why this happens and how to force flushing of those messages at the right time?
I have tried:
Other helpful but unanswered question I have found is: