multithreading - C# not waiting for an async method to finish -
this question has answer here:
i have specific place in code, sending email message. well, not important @ here wait method finished, task should happen in near future, not right now.
i know if safe:
// stuff here... task.run(sendemail); // , here too... don't wait email sent, go!! is alright? method executed? won't lead thread-blocking problems, (given method thread-safe)?
also, way run such task? better call:
sendemail(); provided method async?
public static async task sendemail()
yes, method 'run'. unless there exception raised in method, there nothing prevent method not executed successfully.
if want know state of task after work done, task instance task.run method , check state of afterwards (you want await task before access check if ended successfully). check task.exception property example.
Comments
Post a Comment