Interprocess Communication between c++ and vb.net applications
I have a c++ console application that has a variable, say, vardata. I want my vb.net application to access the content of vardata. I thought I can do that by saving vardata to clipboard and vb.net should get the clipboard text. The problem is that the content of vardata is changing 150 times/second and I am missing a lot of changes when vb.net application is trying to get clipboard text. Is there any ready function i can use to save the data in a memory spac开发者_JAVA技巧e (c++ side) and access it from my vb.net application (vb.net side).
Thanks in advance
Very unhappy number. Sharing memory isn't going to solve it either, your VB.NET program easily loses access to the CPU for 35 msec or more. Missing updates. And you really don't want to burn the cycles to try to keep up, polling is fugly.
The other option is to use a socket or a named pipe. You won't lose any data and won't burn cycles. A corner case is that your C++ program might get bogged down if your VB.NET program isn't responsive.
Do keep in mind that the human eye can't perceive updates that happen faster than about 30 times per second. If this is a GUI requirement then 150 updates per sec is wasted effort that can actually make your GUI freeze.
You should change the VB application into a library and load that into your C++ process. There are various ways to then pass the data; the easiest ones might be to use C++/CLI (in C++) or to create a COM object (in VB).
精彩评论