How to call windows system .dll (CancellationToken)

2 次查看(过去 30 天)
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

采纳的回答

Yash Sharma
Yash Sharma 2023-9-5
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by