I'm trying to learn Windows Phone dev by making a basic app that provides information about Pokemon. To do this, I've created a portable class library (PokeLib.dll) so it's compatible with universal apps. I've tested this via a project in the same solution ("Test"), and it works fine. You can take a look at the code for these on my Github, but as far as I can tell, it's all good. These two projects are in the one solution. For the Windows Phone app's solution, I added PokeLib as an "existing project", added the references, and written some a couple lines of code to make sure I could call it okay:
MainPage.xaml:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Name="GetDataButton" Content="GetData" Click="GetDataButton_Click" Grid.Row="0" HorizontalAlignment="Center"/>
<TextBlock Name="DataText" Text="Click to get data" Grid.Row="1" Padding="10"/>
</Grid>
MainPage.xaml.cs:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
p = new Pokemon(1); // gets data for Pokemon #1 (Bulbasaur)
}
Pokemon p;
int counter = 0;
private async void GetDataButton_Click(object sender, RoutedEventArgs e)
{
DataText.Text = "Fetching... Count: " + ++counter;
if (counter == 1) // first time button's clicked
{
await p.Create(); // populates the data container
DataText.Text = String.Format("Pokemon #{0}: {1}", p.Id, p.Name);
}
}
When I try to run this on a phone emulator, I get the following message:
. I am building the project as "debug" and have "Enable Just My Code" unchecked. I am not sure what to do under the Symbols pane, but I can add a screenshot of that too, if it'd be useful.
Anyway, the app opens, but freezes when I press the GetData button. I expected it would freeze for a moment since that call is done synchronously, but this is permanent. However, no errors/exceptions are thrown. The debugger also doesn't respond when I attempt to step into the p.Create() call (likely stemming from the message in the screenshot).
Anyone have an idea of what I'm doing wrong? Thanks!
p.Create
instead of calling theWait
method. Waiting on the UI thread is bad practice anyway