Task factory issue

I've implemented a function using Task.Factory to call a third-party API for data recording. However, I've been encountering an intermittent issue where, at times, the function is not triggered as expected. Occasionally, the task seems to end before it even starts, and other times, the function never actually executes. This issue has persisted for several days, and I'm seeking a reliable solution to ensure consistent task execution.
22 Replies
Angius
Angius4w ago
That usually means something that should've been awaited, wasn't A reliable solution to execute a Task is to await it We'll need to see some code, though
Gowrishankar
GowrishankarOP4w ago
In the above code I'm facing the issue in ZohoPOAPI Method
Gowrishankar
GowrishankarOP4w ago
Inside GuestEmail and propertyMail also I'm using the Task Factory
Angius
Angius4w ago
That's a lot of task factory usage Why? Also, you should be using await Task.WhenAll() not Tash.WaitAll() I don't see you await anywhere in this method either, so I wonder why it's even async
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
Gowrishankar
GowrishankarOP4w ago
we want so much program run in back ground after the API results , So only we have used the Task factory. Okay, I think you are the genius in C#. So kindly, Change my code which all seems to be like bug and give the correct version It should work in all scenarios.
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
Valwex
Valwex4w ago
We're not your dogs.
Gowrishankar
GowrishankarOP4w ago
I haven't said it like that anywhere. If you feels that, I'm not response for that. I'm Requesting and seeking for help to resolve my problem.
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
Gowrishankar
GowrishankarOP4w ago
First, I'm not said that in anywhere. Then if you feels it like harsh means. I apologizes for that @TeBeCo My issue in the code is only Task factory, the function is not triggered as expected. Occasionally, the task seems to end before it even starts, and other times, the function never actually executes
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
Gowrishankar
GowrishankarOP4w ago
Pauses the current thread for 1 second.
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
Gowrishankar
GowrishankarOP4w ago
after that the code execute
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
Gowrishankar
GowrishankarOP4w ago
what you mean the method?
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
Gowrishankar
GowrishankarOP4w ago
The method name is main
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
Gowrishankar
GowrishankarOP4w ago
after the Console.WriteLine reach, The Task.Run will execute
Unknown User
Unknown User4w ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server