Multi-threading with .net framework
Mostrar comentarios más antiguos
When I run following code, I expect to see mixed printing from both functions. However, they run sequentially not in parallel. How can I change this code to force Matlab prints results from both functions together? Is there anyway without using Parallel computing?
NET.addAssembly(strcat(pwd,'\','NetDocDelegate.dll'));
divDel = NetDocDelegate.delInteger(@Run);
asyncRes{1} = divDel.BeginInvoke(1,[],[]);
if asyncRes{1}.IsCompleted == false
asyncRes{2} = divDel.BeginInvoke(2,[],[]);
end;
function ret = Run(l)
for i=1:100000
display(strcat(num2str(i),'(',num2str(l),')'))
end;
ret = l;
end
Respuestas (1)
Guillaume
el 8 de Mzo. de 2017
0 votos
Matlab is single threaded. There is no way for both delegate to run simultaneously. You would indeed need the parallel toolbox to do something like that.
3 comentarios
Seyedfarid Ghahari
el 8 de Mzo. de 2017
Seyedfarid Ghahari
el 8 de Mzo. de 2017
Editada: Guillaume
el 8 de Mzo. de 2017
Categorías
Más información sobre .NET Events and Delegates in MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!