0

I am working on a xamarin/C# project. I have an event method like this:

        void Handle_SearchButtonPressed(object sender, System.EventArgs e)
        {

        }

Let's suppose i want to call an async method with await like this:

        void Handle_SearchButtonPressed(object sender, System.EventArgs e)
        {
             await my_async_method();
        }

I need to add aync keyword like this:

        async void Handle_SearchButtonPressed(object sender, System.EventArgs e)
        {
             await my_async_method();
        }

It works fine. But, in theory, i should also replace void type by Task. If i do this, i get an error (wrong method signature).

So my question is: Why does it works with void ? In theory it should not work.

Second question: How does it works (internal) to call Handle_SearchButtonPressed without await.

Thanks

Bob5421
  • 7,757
  • 14
  • 81
  • 175

0 Answers0