Using C# delegate to transfer progress

조회 수: 1 (최근 30일)
Bart Smits
Bart Smits 2016년 2월 19일
댓글: Walter Roberson 2016년 2월 19일
I have created a Matlab calculation routine and compiled it to a .NET assembly. This assembly is used in a C# web-application. To give feedback of the progress from the Matlab routine I want to call a method in C#. For this I use a delegate.
namespace NetSample
{
public delegate void Del(double com);
public class NetSample
{
public Del MyDel;
private MatlabCalculator matlab;
public NetSample()
{
matlab = new MatlabCalculator();
}
public void Run()
{
matlab.test();
matlab.Dispose();
}
}
}
Within Matlab I register the method Print to this delegate:
function test
NET.addAssembly('C:\Program Files\Matlab\R2015a\extern\examples\NET\NetSample\bin\Debug\NetSample.dll');
%NET.addAssembly('NetSample.dll');
myClass=NetSample.SampleMethods;
myDel=NetSample.Del(@myClass.Print);
for ii=1:100
fprintf('Call delegater');
myDel(ii);
end
myDel.delete();
end
This routine works except that when the C# routine has stopped it gives an error as given in the attached file. Can you give me advise to correct this problem?

답변 (0개)

카테고리

Help CenterFile Exchange에서 .NET Events and Delegates in MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by