Created
May 5, 2013 09:19
-
-
Save damirarh/5520255 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private readonly Task _initializingTask; | |
public ViewModel() | |
{ | |
_initializingTask = Init(); | |
} | |
private async Task Init() | |
{ | |
var file = await Package.Current.InstalledLocation.GetFileAsync(@"Assets\Text.txt"); | |
Text = await FileIO.ReadTextAsync(file); | |
} | |
private async void OnSomeCommand() | |
{ | |
// check if initialization is complete | |
if (_initializingTask.IsCompleted) | |
{ | |
// do some action | |
} | |
// or even await the initialization to complete if it hasn't already | |
await _initializingTask; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment