Using C# delegate to transfer progress
1 回表示 (過去 30 日間)
古いコメントを表示
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 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!