Linked Questions
118 questions linked to/from await vs Task.Wait - Deadlock?
137 votes
5 answers
99k views
An async/await example that causes a deadlock
I came across some best practices for asynchronous programming using c#'s async/await keywords (I'm new to c# 5.0). One of the advices given was the following: Stability: Know your synchronization ...
6 votes
2 answers
6k views
Task.WaitAsync vs Task.Wait [duplicate]
I know that Task.Wait() block thread in which it is executed. Do I understand correctly that Task.WaitAsync() does not do this? I tried to find information about it but I didn't find anything
8 votes
1 answer
10k views
Difference between await and Task.Wait [duplicate]
First way: var tds=SearchProcess(); await tds; public async Task<XmlElement> SearchProcess() { } Second way: var tds= Task.Factory.StartNew(()=>SearchProcess()); Task.WaitAll(tds); ...
3 votes
1 answer
5k views
Hanging with WaitForConnectionAsync() on pipe [duplicate]
I'm communicating with another process via named pipes. The pipe server is implemented in C# and the client is written in C. The server is a WPF application. I need to create a NamedPipeServerStream ...
2 votes
1 answer
3k views
Not receiving response after PostAsync [duplicate]
I have next part of code : using (var client = new HttpClient()) // from Windows.Web.Http; { //setup client var tokenUri = new Uri(apiBaseUri + "/token"); client.DefaultRequestHeaders....
0 votes
1 answer
1k views
Can you do GET request inside HTTP POST by calling .Result on async method? [duplicate]
I have a service that calls API GET request and return boolean. Task<bool> LoginExist(string email, string password); In the controller, I have the code below: [HttpPost] public ...
1 vote
2 answers
2k views
Deadlock at consuming rest API [duplicate]
So I built a small program to consume a REST api, but it never finishes beacuse no data is received. I'm new to using Async and wait commands, so I have probably gotten it wrong somehow. The threads ...
1 vote
0 answers
1k views
What is the difference between Task.Run(async).Wait() and sync method? [duplicate]
I am implementing method for seeding data (and calling it in Startup.Configure() method) which looks like if(!_context.Table.Any()) { _context.Table.Add(); _context.SaveChanges(); } And I want ...
0 votes
2 answers
367 views
Why does TPL not deadlock when using await with continueOnCapturedContext:true? [duplicate]
This question is different from await vs Task.Wait - Deadlock?. That question deals with a case where (purportedly) await causes a deadlock, and .Wait doesn't. This question is the reverse. ...
0 votes
0 answers
752 views
How to use async in sync code? [duplicate]
Async method (works fine in async code): public async Task<ServiceResult<Config>> GetConfigAsync(string id) { var entity = await _entityRepo.FindAsync(t => t.Id == ...
0 votes
0 answers
216 views
Can't await task on MainWindow Loaded event [duplicate]
I can't await my task when i load window. I have three viewmodel, with three initialize, and this three initialize have 1 async method to return data from database, and 1 synchronous method. If i try ...
0 votes
1 answer
133 views
Await.Task<>.Run freezing after finish [duplicate]
I am running an await Task< >.Run(() => inside an async method. The code in the await runs to competition but never returns. The next line after the await never gets called. Anyone have any ...
4 votes
0 answers
114 views
C# Task.Delay(1).Wait() deadlocks but only if inside another Task [duplicate]
I can't figure out why Task.Delay(1).Wait() does not block the UI thread when called directly, but does when wrapped inside another Task that is then syncrhonously waited on. Take for example this ...
0 votes
0 answers
71 views
HttpClient.PostAsync hanging Windows Phone app [duplicate]
What could possibly be wrong with the following method? The whole app hangs after calling the "await" line... protected async Task<T> PostRequest<T>(string resourceEndpoint, JObject ...
0 votes
0 answers
54 views
SendGrid hanging only in web app (not in console app) [duplicate]
So i have a bit of a weird things going on. I'm trying to get SendGrid v9 working on my web app. I've run this through a bunch of test, including creating a console app to test. It works great in the ...