How to call windows system .dll (CancellationToken)

7 views (last 30 days)
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

Accepted Answer

Yash Sharma
Yash Sharma on 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.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!