There is a library, it defines methods with entities that are incomprehensible to me. Here are the definitions of the methods.

<AsyncStateMachineAttribute(GetType(<GetAnswer>d__9))> Public Function GetAnswer(ImageFilePath As String, ct As CancellationToken) As Task(Of String) <AsyncStateMachineAttribute(GetType(<GetAnswer>d__10))> Public Function GetAnswer(Img As Image, ct As CancellationToken) As Task(Of String) 

The question of how to correctly call the GetAnswer method and "what to eat with" CancellationToken

 Dim retval As String = Await rucap.GetAnswer("", ??? ) 
  • Please refrain from editing the question, which completely change its meaning. If you have a new question - ask it as a separate question, giving a link to the original. And do not turn the question into a post about finding a solution with the addition of udp as you progress. - PashaPash
  • I strongly disagree with your edits! - Dmitriy Gvozd
  • one
    I did not make any changes, I just rolled back the question to its original version. The topic of actual adjustment of the issue was most recently discussed on a site . I suggest you to issue upd-s as a full-fledged, integral question (with a code to reproduce the problem), if they are still relevant. - PashaPash

1 answer 1

You need to create a CancellationTokenSource , and pass the value of the Token property as an argument. By calling the Cancel method on the source or setting a time limit, you can interrupt the operation.

If the interruption of the operation does not interest you, you can simply pass the CancellationToken.None .

  • Not everything is so simple as it turned out, can you tell me how to solve the following problem? - Dmitry Gvozd
  • @DmitryNight You can try to use the Result property of the returned Task . - Athari
  • How to do this if I have not worked with this before ... I do not understand what you are trying to do. - Dmitry Gvozd
  • one
    @ Dmitriy Nail You would read about async / await, and then pile up crutches, then you will guess why everything is hanging or running slowly. Those functions that interest you, return Task(Of String) - this is not a magic object, you can perform operations with it. In particular, it has a Result property that waits for the end of an asynchronous operation, blocking the current thread. GetAnswer("", CancellationToken.None).Result , actually. - Athari
  • There are new circumstances, they are in the update. - Dmitriy Gvozd