Passing a MATLAB object-handle through a .NET call

조회 수: 4 (최근 30일)
Gary
Gary 2019년 7월 15일
I would like to pass a MATLAB object handle with an asynchronous .NET call, so that it can be passed back to the same MATLAB instance and resolved as an object reference.
The specific case is that I am using a Windows Named Pipe for interprocess communication between another application and MATLAB. To use the pipe asynchronously, I issue the following call from a MATLAB object 'pclient' of class 'PipeClient' (which I defined):
pclient.Stream.BeginRead(pclient.Buffer,0,pclient.BufferSize,@pipeClientReadCallback,STATE);
The last parameter STATE in this .NET call can be any object translatable into the call, and its purpose is that it is passed back to the ReadCallback function. I can send a number, or a pointer to a System.Byte[] array created in MATLAB, but ideally I would pass a reference to the pclient object.
If I could convert a MATLAB object handle into a number (and later convert it back again), this would allow me to code this cleanly. As it is now, I have a workaround in which the callback refers to a global object containing pClient, but this seems unaesthetic.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Microsoft .NET에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by