1- Checking for data periodically by calling getData
will make the client inefficient and more complex, so I would not recommend this.
2- Using a shared MemoryStream
is a solution that can be investigated
Another alternative, and probably simpler, solution is to simply pass a callback
object to your library that is called whenever a new data is available i.e. event-driven
communication