Question: My code looks like this:

```
    public void Init() {
        if (AS.pti == PTI.UserInput)
        {
            AS.runCardTimer = false;
        }
        else
        {
            AS.runCardTimer = true;
            Device.BeginInvokeOnMainThread(() => showCards().ContinueWith((arg) => { }));
        }
    }

```

The Init method is called from the constructor. Can someone please explain to me why the developer might have added the Device.BeginInvokeOnMainThread() instead of just calling the method showCards?

Also what does the ContinueWith((arg)) do and why would that be included?

Answer: 
The class where this `Init()` method is might be created on a background thread. I'm assuming `showCards()` are updating some kind of UI. UI can only be updated on the UI/Main thread. `Device.BeginInvokeOnMainThread()` ensures that the code inside the lambda is executed on the main thread.

`ContinueWith()` is a method which can be found on `Task`. If `showCards()` returns a task, `ContinueWith()` makes sure the task will complete before exiting the lambda.
UI actions must be performed on UI thread (different name for main thread). If you try to perform UI changes from non main thread, your application will crash. I think developer wanted to make sure it will work as intended.