Using C# delegate to transfer progress

1 vue (au cours des 30 derniers jours)
Bart Smits
Bart Smits le 19 Fév 2016
Commenté : Walter Roberson le 19 Fév 2016
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 commentaire
Walter Roberson
Walter Roberson le 19 Fév 2016
No file appears to be attached?

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by