My application contains two sides - client side on c++ and server side on c#. I need client side to receive structure with lowest possible latency. So I want it to receive a pointer to a structure and avoid marshaling. Structure is something like that:
struct OrderAction
{
OrderActionType actionType;
uint UserId;
int OrdersExecutorId;
int InstrumentId;
int StrategyId;
....
So I think i want to do this:
- Server c# side pass pointer to client c++ side.
- At c++ side read and process struct by received pointer.
- At c# side free resources (delete struct) if needed.
In future I plan to replace c# server side with c++ server side so I want client to be completely independent. Client shouldn't know that it called and used from c#.
Questions:
- Should I use this algorithm?
- If so then at step 1 should I allocate structure at managed memory or unmanaged memory?
- What methods should I use and probably someone can link an example?