Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

Using overlapped I/O in .NET

$
0
0

Hello,

I'm looking to implement my own buffered IO stream, based on the Win32 asynchronous (overlapped) model. I don't find any helpful documentation or examples how this can be used. I'm learning by implementing a serial driver based on the WaitCommEvents, ReadFile, WriteFile api.

The System.Threading namespace has Overlapped and NativeOverlapped. I don't understand how Overlapped is used in much detail, nor do I know how it works.

  • How/when is the callback is called?
  • In what context is the callback called?
  • Do I need to worry about GC Pinning, and/or AllocHGlobal?
  • How does all this relate to IOCP's and the ThreadBind() function?
  • What should my class based on IAsyncResult have? How is this used?

All real examples I find are related to C/C++ (which would translate to NativeOverlapped) but nothing for the .NET Overlapped class.

I'm trying to decide how the event loop will look. Traditionally I've programmed such things in Posix with a select() call and based on the FD and result I would execute a function. Similarly, I had thought of having an event thread that waits on mutexes, based on this it was the result of a read/write/event. The RXCHAR behaviour makes things just that little more interesting though, in the case my local buffer is full, I can't read data, but the RXCHAR event won't fire so long as the buffer isn't empty.

Thanks in advance,
Jason.

11 Aug 2012, Update:

  • After reading the examples on overlapped Pipe I/O I understand the programming model when uisng overlapped I/O in C. However, the usage of the Overlapped class in .NET still aludes me.

Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>