1.)
There is no reason to use a GCHandle in your code.
If you read the documentation that this is for the opposite purpose: When UNmanaged code accesses Managed resources.
But you not do this in your code.
2.)
There is absolutely no need to ever use the keyword "unsafe" in your code and require to compile you code as unsafe.
3.)
It does not make sense to use hundreds of "async" and "Task" if you use "await" in the same function.
You did not understand asynchronous programming.
If you use "await" in the same function you block the calling thread. This is not asynchronous programming anymore.
The idea of asynchronous programming is that one thread waits for another and not one function blocks itself.
4.)
Why pass a CancellationToken to each and every function if you have a timeout of 1500 ms ?
Who will ever cancel such a short operation ?
1.)
There is no reason to use a GCHandle in your code.
If you read the documentation that this is for the opposite purpose: When UNmanaged code accesses Managed resources.
But you not do this in your code.
2.)
There is absolutely no need to ever use the keyword "unsafe" in your code and require to compile you code as unsafe.
3.)
It does not make sense to use hundreds of "async" and "Task" if you use "await" in the same function.
You did not understand asynchronous programming.
If you use "await" in the same function you block the calling thread. This is not asynchronous programming anymore.
The idea of asynchronous programming is that one thread waits for another and not one function blocks itself.
4.)
Why pass a CancellationToken to each and every function if you have a timeout of 1500 ms ?
Who will ever cancel such a short operation ?