Pass values between C# and C language in Windows CE

Do we have any method by which we can pass values between C# and C language in Windows Embedded Compact OS.?

We have an application like this.

We have to collect data using UART from different slaves display it using 7inch RGB LCD. Also do some control function on the collected data. So our display program and UART program should always exchange the data. We have implemented this project completely using C# but the project source is not efficient since C# powerful features of C like pointers ,structure ,sizeof etc.

So we thought why not use C for this control algorithm (collecting data from UART ,Processing data etc)and C# for user friendly display. But the problem of data sharing is bothering us.

Can we have any solution for this??

Or how people are doing display related project. Is there any better soltion then going for windows forms using C# in Windows CE OS?

Please help us out.

There are are many different ways to exchange data between C and C# code.
You may have code running inside the same process, so C# code can call C functions (you need to remove C++ decorations if you are using C++, at least from interface functions) or have C code calling C# callbacks. In this case you usually load a C DLL inside your C# process. Managed callbacks may add some delays to C code and so you should avoid them if your code has to grant latencies.

You may also use point-to-point message queues:

This works well also across different processes and is designed to allow them to exchange a small amount of data without blocking while the receiver is processing it.

If you need to share a large amount of data then you may consider shared memory (inside the same process or across process boundaries) and synchronize access to it using critical sections (more efficent but working only inside same process) or mutexes and events.

As you can see it’s not an issue of not having solutions but, maybe, having many and having to choose the best one for your specific scenario.