我的问题非常特定于matlab编译器和运行时的神秘面纱.由于只有熟悉matlab运行时API的人才能回答,所以我缩短了很多细节.如果我应该更加冗长,请告诉我.
使用matlab编译器和运行时,我可以调用一个用C#程序的m代码编写的函数.我们说要打电话:
function [result] = foo(n)
%[
result = 0;
for k = 1:n,
pause(1.0); % simulate long processing
result = result + 42;
end
%]
Run Code Online (Sandbox Code Playgroud)
with(在C#代码中的一些dllimports后面的某个地方):
mclFeval(IntPtr inst, string name, IntPtr[] plhs, IntPtr[] prhs)
Run Code Online (Sandbox Code Playgroud)
到目前为止,非常好,我对此没有任何问题(即初始化运行时,加载'.cft'文件,使用.Net类型来回编组MxArray等等)
我想foo用一些cancel和progress回调来调查我的函数的进展:
function [result] = foo(n, cancelCB, progressCB)
%[
if (nargin < 3), progressCB = @(ratio, msg) disp(sprintf('Ratio = %f, Msg = %s', ratio, msg)); end
if (nargin < 2), cancelCB = @() disp('Checking cancel...'); end
result …Run Code Online (Sandbox Code Playgroud)