C
C#

help

❔ Async Await On Logging - Waiting Response Without Await Keyword

ACAtakan / Cracker12/14/2022
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 Callstack is as listed below
ACAtakan / Cracker12/14/2022
1 (here calling logger.log without await keyword but the service calls this method is still waiting)
ACAtakan / Cracker12/14/2022
2
ACAtakan / Cracker12/14/2022
3
ACAtakan / Cracker12/14/2022
4
ACAtakan / Cracker12/14/2022
Sorry for images, I am on VPN 1 -> 2 -> 3 -> 4
AAngius12/14/2022
One thing that comes to mind is perhaps explicitly disposing the task? _ = FireAndForgetAsync()
ACAtakan / Cracker12/14/2022
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
Pphaseshift12/14/2022
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'
ACAtakan / Cracker12/14/2022
That's right, there is long running cpu bound sync operation inside await PrepareData 4th image thats where I replaced with await Task.Delay
AAccord12/15/2022
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.

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended 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 S❔ 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❔ 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 coSearch generic list for a searchwordHeeelp! deadline soon and i'm stuck.. I have a list like this: List<string[]> blogPostList = new()Remove or overwrite single element of list of arrays(not completely sure its called list of arrays) Basically i have one of these: List<string[]> blog✅ When calling a generic function, how can I tell it that I'm going to be passing null?I've got a generic function which is something like this: ```cs public ReturnType GetValue<ReturnTyp❔ WPF Textbox decimal onlyHello, i'd like to know how we are supposed to configure our textbox in order to accept only decimalmaui deserialize problemI am having a problem when trying to deserialize api data ```C# string content = await response.C❔ Log from helper class without creating new context? (Serilog)I have a bunch of services with their own dedicated loggers that have config'd settings for filterin❔ Swagger Open API not showing Request examples in the UII've written an Azure Function with Open API in C#, but when I open up the Swagger/UI to test my Azu❔ I'm building an MVC core webshop. How should I be structuring controllers, actions and views?So, right now, I have one single view, and this view renders both information about the product and ❔ How to make an object follows my mouse?so I am new at programming and trying to make a top down shooting games in windows form app. My lect❔ Is this the right way to implement an Interface```csharp interface IObstacles { void Draw(Graphics g); } class Redbox : IO❔ Is it possible to have WPF window hidden until Blazor WebView loads page?I'm trying to hide a WPF window until the Blazor WebView loads, but it seems that the initialization❔ SQLite in-memory Database read from ReadOnlyMemory bytesI'm receiving an SQLite database payload from an AMQP-0-9-1 message in the form of `ReadOnlyMemory<b