How to call windows system .dll (CancellationToken)

7 vues (au cours des 30 derniers jours)
Charlie Walker
Charlie Walker le 31 Août 2023
Commenté : Charlie Walker le 20 Sep 2023
Hi Everyone,
I am currently trying to connect a ball bar sensor made by Renishaw to matlab for data collection, I have been given an API from the manufacturers who have never connected it to matalb before.
To do this I need to call a Windows CancellationToken which should be in System.Threading also stated here https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken?view=net-7.0
But when I try adding the System.Threading using NET.addAssembly('System.Threading') the assembly is empty. if I use NET.addAssembly('System') I get 664 classes but I can not see CancellationToken.
My Question is how do I call a CancellationToken or is it not possible?
Thank you for any help

Réponse acceptée

Yash Sharma
Yash Sharma le 5 Sep 2023
Based on my understanding, you are trying to access the CancellationToken class from System.Threading, but it seems that the class is actually located in the "System.Runtime" assembly, as per the documentation link mentioned. To use CancellationToken, you can follow these steps:
% Set up the .NET environment for Core:
>> ne = dotnetenv("core");
% Add the "System.Runtime" assembly:
>> asm = NET.addAssembly('System.Runtime');
% Access the classes within the assembly:
>> asm.Classes
By executing these commands, you should be able to find the CancellationTokenSource class, which can be used further.
Find below the documentation of dotnetenv and NET.addAssembly functions.
  1 commentaire
Charlie Walker
Charlie Walker le 20 Sep 2023
Thank you for this it really helped

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by