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?
  1 件のコメント
Walter Roberson
Walter Roberson 2016 年 2 月 19 日
No file appears to be attached?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File 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