Just another C# async/await Question
Go to solution
Solved by MisterWhite,
PipelineItem.DoSomething() is an async Task method with an await keyword in it, so yes if you plainly invoke a PipelineItem.DoSomthing it will run asynchronously. I am not familiar with ActionBlock and it's implementation so there might something there and how you use
testBlock.Complete(); testBlock.Completion.Wait()
Keep in mind that an async method runs code synchronously until it encounters an await keyword so
private async Task<PipeLineItem> RunIfNotCancelledAsync(Func<Task<PipelineItem>> function) { if (!_isCancelled) return await function(); else return new PipelineItem(true); }
runs synchronously if _isCanceled is true.
Also try to keep the method naming the same. If it's an async method add Async to ir => DoSomethingAsync() as with RunIfNotCancelledAsync
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now