First of all, if Presenter.Search
already returns a Task
you should consider to make the event handler async
and simply put
await Presenter.Search();
in the try-catch block.
The reason of Task.Run(Func<Task>)
overload exists is that you can force an already existing Task
to be scheduled for execution on a pool thread. This case can be justified in very rare cases as normally you should rely on the internal implementation of the Task
returning methods. But if you know that an async method does not use threads (for example, just returns a Task
, which will be completed on a specific event) and you are confident enough about forcing the execution on a pool thread you can do it this way. But also in this case you should await the external task; otherwise, the call is fire-and-forget and you will not catch anything:
await Task.Run(() => Presenter.Search());
Please note that I omitted the inner async-await:
await Task.Run(async () => await Presenter.Search());
This would also work and is functionally equivalent to the previous version but adds a needless inner state machine to the chain of tasks to execute.
TL;DR: Without knowing any further details await Presenter.Search();
seems to be the better solution but also await Task.Run(() => Presenter.Search());
can be justified if you know what you are doing.