bchip
Expert Member
- Joined
- Mar 12, 2013
- Messages
- 1,324
- Reaction score
- 418
Hi everyone
Im playing around with a project and getting an annoying bug. Hopefully someone knows their way around it.
On the startup of a C# .NET application I connect to a postgresSQL server and send a basic SELECT query.
It simply asks for all the accounts in the database to be loaded into the application.
Sometimes the application comes back with data, and other times it doesnt.
If I debug with breakpoints it always comes back with the data, which made me suspect that
it had to do with the timing of the query.
So with that then, I next tried to add async/await into the process.
Maybe the connection is taking longer than expected? Maybe its the query? Not sure
So I added in async and didnt work, the application froze.
So next I tried to simply add a Task.Delay(1000) to make sure its not the connection or anything giving issues.
Even the Task.Delay is freezing. Did some further googling and found that its likely that the await command
freezes the whole process including the Task.Delay - hence why it doesnt continue at all....just pauses indefinitely.
Any ideas how to get around this? All Im trying to do is make sure that everytime I request data from the DB
it returns and then continues (which is what sync programming is suppose to do...pause until its finished)
Any help will be much appreciated.
Thanks
Im playing around with a project and getting an annoying bug. Hopefully someone knows their way around it.
On the startup of a C# .NET application I connect to a postgresSQL server and send a basic SELECT query.
It simply asks for all the accounts in the database to be loaded into the application.
Sometimes the application comes back with data, and other times it doesnt.
If I debug with breakpoints it always comes back with the data, which made me suspect that
it had to do with the timing of the query.
So with that then, I next tried to add async/await into the process.
Maybe the connection is taking longer than expected? Maybe its the query? Not sure
So I added in async and didnt work, the application froze.
So next I tried to simply add a Task.Delay(1000) to make sure its not the connection or anything giving issues.
Even the Task.Delay is freezing. Did some further googling and found that its likely that the await command
freezes the whole process including the Task.Delay - hence why it doesnt continue at all....just pauses indefinitely.
Any ideas how to get around this? All Im trying to do is make sure that everytime I request data from the DB
it returns and then continues (which is what sync programming is suppose to do...pause until its finished)
Any help will be much appreciated.
Thanks