❔ Async Await On Logging - Waiting Response Without Await Keyword

I have logging service where I call the logger.log async method without awaiting the response, expected behaviour is that the method calls logger.log will return the response without await the log response, but its otherwise
11 Replies
atakancracker
atakancracker2y ago
Callstack is as listed below
atakancracker
atakancracker2y ago
1 (here calling logger.log without await keyword but the service calls this method is still waiting)
atakancracker
atakancracker2y ago
2
atakancracker
atakancracker2y ago
3
atakancracker
atakancracker2y ago
4
atakancracker
atakancracker2y ago
Sorry for images, I am on VPN 1 -> 2 -> 3 -> 4
Angius
Angius2y ago
One thing that comes to mind is perhaps explicitly disposing the task? _ = FireAndForgetAsync()
atakancracker
atakancracker2y ago
I am not sure how does disposing task works, don't think I have similar operation We have old SQL Bulk Insert code, there used Task.Factory.StartNew for each log item. I haven't use it here but still If I dont await the async task then it should behave fire and forget way I have debugged the bulk insert method without using Task.Factory.StartNew and it behave the same There is a method resizing request data for optimize space on database, that operation cpu bound work I replaced that method with Task.Delay and it works properly now I can't see why
phaseshift
phaseshift2y ago
You replaced some code you didn't show here? Adding in a task.Delay is adding a point for the async state machine to start. Sounds like you were calling a lot of long running sync code before the first chance for the state machine to 'go async'
atakancracker
atakancracker2y ago
That's right, there is long running cpu bound sync operation inside await PrepareData 4th image thats where I replaced with await Task.Delay
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ Validate Crypto addressI want to validate a cryptoaddress. The user can input an cryptoaddress... I want to validate this..✅ Creating a generic type based on a Type variable rather than a specific typeI've got the following code: ```cs public class QueryResponse<T> { T? Data { get; set; } bool Swhen an enemy hits the player it doesn't stop for some reason, and when the form loads I can't moveI'm not sure what I'm doing wrong when a bulletbill hits the bird it should stop and show up a messa❔ C Sharp Windows Form executable with local databaseHello guys, I've made a project in C# Windows Forms that uses local database (Azure). Since it's loc❔ Process.Exited immediately fired if corresponding app is already openedI wrote a function that downloads a PDF from some API and then attempts to open it. For this reason,❔ [Avalonia UI] - How to bind a process method to PointerPressed in ScrollViewer in xaml?Quite confused. It's not quite same as WPF and I cannot find anything in official document.✅ Using Linq's Cast MethodI've never been able to get it to not warn and throw errors except for one, maybe two times. It is a❔ Binary tree pre orderHow to make a loop out of this ? ``` Tree tree = new Tree(); tree.root = new Node(1); tr❔ How do I resolve the SocketException (10061)?I keep getting **System.Net.Sockets.SocketException (10061): A connection could not be made because ❔ rename tuple```csharp public async Task<(List<SalesReportEntity>, int totalSales)> GetAllSalesReportAsync(int co