Making third party I/O DLL asynchronous

  async-await, c++

I need to use a third-party DLL which implements a TCP socket client (in C++) using blocking calls. So basically (pseudocode);

void DoRequest()
{
  send(myblockingSocket,data); 
  recv(myblockingSocket,responsedata);
}

What is the recommended way to make these calls accessible in .NET as asynchronous calls using async-await (without changing the original DLL) ?

I read: https://docs.microsoft.com/en-us/dotnet/standard/async-in-depth#deeper-dive-into-tasks-for-an-io-bound-operation and https://docs.microsoft.com/en-us/dotnet/csharp/async and several other pages and did not find another solution than spawning a new task, which is not recommended to do on I/O bound operations because of the task creation overhead.

Source: Windows Questions C++

LEAVE A COMMENT