Using C# delegate to transfer progress
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Respuestas (0)
Ver también
Categorías
Más información sobre .NET Events and Delegates in MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!