c# - Task.Factory.FromAsync with CancellationTokenSource -


I have the following line of code used by Network Stream to read asynchronous:

  BitsRed = wait job & lt; Int>. Factory.FromAsync (this.stream.BeginRead, this.stream.EndRead, buffer, 0, buffer, length, faucet);  

I want to support this cancellation. I think I can see, though I can not pass it in any way.

Is it possible to cancel one Sensex () - construction work support?

EDIT: I want to cancel a task that is already running. Gigi, Unfortunately, offsink means the nature that indicates that you only get TPL API (TPL =). In order to optimize asynchronous propagating,

In short, TDSL's RedSync controls ASCIC behavior only, while when AASIC only wraps the behavior (but does not control it).

Now there is a TPL specific construction since the cancellation, and since there is no control over the internal functioning of the Async system, therefore, to cancel the work clearly and to ensure that Not guaranteed that all resources are properly locked (This is why it was abandoned. If you are curious, then only decompile the method;))

In these situations, the actual async In call Etne is more understandable. The Nd OperationCancellalian detects the exception, which will give you the opportunity to turn off your stream by making the appropriate call.

In short, the answer is not , but you have nothing to stop, by creating a generic overloaded method, to select the right strategy to clean a stream cleanly on that type of basis. Will be.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -