By searching the web, I found a convenient answer to my problem.
I had an other
async
/
await
in my
GeneratePdfReportAsync
method, and I've discovered that a
Task
or
Task<T>
object need the UI Thread to be available. But in this case for this method, I didn't need the UI Thread, but it was still accessing it to verify the result of my task and so blocking my UI until all my tasks were finished.
The solution was that during the await from other method in the
GeneratePdfReportAsync
method, I've added
ConfigureAwait(false)
witch tells the Task not to call the UI.
messages = await ClientInfoManager.GetMessagesFromClientAsync(client, true).ConfigureAwait(false);
I've found the solution to my problem thanks to a very helpful tutorial for asynchronous and parallel programming on C#.
Links :
Part 1
Part 2