I have a series of functions that I use as a base for my ViewModels. These get overloaded in each class that uses the baseviewmodel.cs.
Here's an example.
BaseViewModel.cs
....
public Task InitBase { get; internal set; }
public Task Initialization { get; internal set; }
public Task InitInventory { get; internal set; }
....
InventoryPageViewModel.cs
public InventoryPageViewModel : BaseViewModel
public InventoryPageViewModel()
{
InitBase = CustomInitializationFunc(); //This code executes the CustomInitializationFunc
}
public async Task CustomInitializationFunc()
{
... some initialization class ...
}
The problem I have is this. When the InitBase is assigned, it is running the code in the function being assigned. The function has code that can only be executed after the page has been loaded, I can add code to prevent the function from running unless a flag is set for the page being ready. However It would be easier to be able to run the initialization without having to execute the function as it's being assigned. Later in the code I will use await InitBase; to execute the function, but
I hope this makes sense.
Cheers!