I'm wodering what happens in the scenario where an discarded Task throws?
As noted in the other answer, TaskScheduler.UnobservedTaskException
is raised. By default, exceptions from discarded tasks are ignored.
Do I need to worry about/handle it? (i.e. security issues, memory leaks or annything else..)
I strongly recommend against discarding tasks. The main reason behind this recommendation is that the containing application cannot know whether it is safe to shut down. Any ongoing work is terminated when the containing application exits. So if you're fine with SendMailAsync
silently doing nothing when the application shuts down, then go ahead and discard. But if you actually want the email to be sent (or a log message on failure), then you should be await
ing the task.