2

I am working to create a C# .NET application (single threaded). I am in need to receive data from an existing MFC application running on the same computer. My .NET application is event driven from some windows form objects like buttons and such, as well as a serial port input. So for example, my event handler is called only when there is new serial data. I am wondering if there is an IPC mechanism that could be setup in an event driven way as well? I was looking at named pipes but haven't seen any examples online of others using it in this way.

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
Michael Bauer
  • 183
  • 4
  • 15
  • Side note: don't add tags to title and [skip thank you notes](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts)/tagline in future post. – Alexei Levenkov Mar 28 '14 at 18:13
  • Same for sockets and named pipes, you'd use BeginRead(). The callback runs when something is received. – Hans Passant Mar 28 '14 at 18:59

1 Answers1

1

WCF includes a mechanism for handling callbacks and events. This can be configured to work over named pipes if you're on a local machine, which makes it very fast and efficient.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
  • Thanks, I read up on WCF and looks like that is the preferred API for loads of interfaces. thanks. – Michael Bauer Mar 28 '14 at 18:11
  • I do have some follow up questions. I looked at a couple of simple examples of WCF using named pipes. I am wondering if it is going to be possible to use a non-.NET application like my existing MFC application to communicate with the WCF named pipe? In the examples I saw I didnt see the name explicitly given, so I am a little confused on how the MFC app would connect. – Michael Bauer Mar 28 '14 at 20:23
  • Also, the example had a more advanced interface which would allow for a function call from the client. I dont know how the MPC app would know about this interface. I was expecting it would be more like serial communication - just reading and writing bytes from the pipe. – Michael Bauer Mar 28 '14 at 20:24
  • @MichaelBauer It's difficult (though not impossible) to have non-.NET clients connect to WCF. Typically is easier to use C++/CLI or COM to allow you to write the client in .NET code, and access it from your MFC project. – Reed Copsey Mar 29 '14 at 20:16
  • 1
    The link now redirects to a generic page about Microsoft magazine. – piedar Jul 29 '16 at 15:21