J
jkimmel
I am having trouble designing an interface between the managed and
unmanaged layers of an application I'm writing.
My application has two parts. A C DLL that generates key/value pairs
(the same 300 keys have new values 10 times a second), and a C#
application that processes those values. Some metadata gets generated
every update as well. The DLL must be unmanaged C.
My question is, how should I transfer the values from the C DLL to the
C# app? A hashtable seems like the obvious choice, but I don't know
that one can be marshaled. Should I register a list of keys I'm
interested in with the C DLL, and then use a structure to get back the
values (as an array), plus the metadata?
And how do I notify the C# application that new data has arrived? A
callback is my first inclination, though from googling it sounds like
callbacks to unmanaged code is hard in .NET. Polling or some type of
messaging system are the only other alternatives I see, and I'm
worried I'll miss update cycles with those.
Another thing to consider is this C DLL may need to be used in a matlab
application as well. I don't know much about matlab programming, but
does this limitation preclude me from using callbacks (or any of your
suggestions)?
Any help/suggestions would be greatly appreciated. Thank you.
J. Kimmel
unmanaged layers of an application I'm writing.
My application has two parts. A C DLL that generates key/value pairs
(the same 300 keys have new values 10 times a second), and a C#
application that processes those values. Some metadata gets generated
every update as well. The DLL must be unmanaged C.
My question is, how should I transfer the values from the C DLL to the
C# app? A hashtable seems like the obvious choice, but I don't know
that one can be marshaled. Should I register a list of keys I'm
interested in with the C DLL, and then use a structure to get back the
values (as an array), plus the metadata?
And how do I notify the C# application that new data has arrived? A
callback is my first inclination, though from googling it sounds like
callbacks to unmanaged code is hard in .NET. Polling or some type of
messaging system are the only other alternatives I see, and I'm
worried I'll miss update cycles with those.
Another thing to consider is this C DLL may need to be used in a matlab
application as well. I don't know much about matlab programming, but
does this limitation preclude me from using callbacks (or any of your
suggestions)?
Any help/suggestions would be greatly appreciated. Thank you.
J. Kimmel