From: gu.martinm@gmail.com Date: Fri, 15 Aug 2014 22:15:24 +0000 (+0200) Subject: RemoteAgents WP8 X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=ae074645d208fa6fccda379a509b486b2c60a9c3;p=CSharpForFun%2F.git RemoteAgents WP8 Using ConfigureAwait(true) (it is the default value) just when I want to update the UI. --- diff --git a/WindowsPhone/RemoteAgents/RemoteAgents/MainPage.xaml.cs b/WindowsPhone/RemoteAgents/RemoteAgents/MainPage.xaml.cs index 76c967c..bb16625 100644 --- a/WindowsPhone/RemoteAgents/RemoteAgents/MainPage.xaml.cs +++ b/WindowsPhone/RemoteAgents/RemoteAgents/MainPage.xaml.cs @@ -38,10 +38,12 @@ namespace RemoteAgents { try { + // Returning data in the same context (the UI thread) because we want to update the UI. this.CurrentDateTextBox.Text = await _view.GetCurrentDateAsync(); } catch (Exception exception) { + // TODO: Should I catch exceptions in the UI thread? I guess it is right but not sure... _logger.ErrorException("ButtonGetDateClicked error: ", exception); } } @@ -56,6 +58,7 @@ namespace RemoteAgents } catch (Exception exception) { + // TODO: Should I catch exceptions in the UI thread? I guess it is right but not sure... _logger.ErrorException("SendDataButtonClicked error: ", exception); } } diff --git a/WindowsPhone/RemoteAgents/RemoteAgents/View/View.cs b/WindowsPhone/RemoteAgents/RemoteAgents/View/View.cs index 29f225c..dc1bcb7 100644 --- a/WindowsPhone/RemoteAgents/RemoteAgents/View/View.cs +++ b/WindowsPhone/RemoteAgents/RemoteAgents/View/View.cs @@ -9,12 +9,14 @@ namespace RemoteAgents.WindowsPhone.View async public Task GetCurrentDateAsync() { - return await _vm.GetCurrentDateAsync(); + // Returning data in a diferent context. Upper layer decides. + return await _vm.GetCurrentDateAsync().ConfigureAwait(false); } async public Task SetWriteTextAsync(string text, int number) { - await _vm.SetWriteTextAsync(text, number); + // Returning data in a diferent context. Upper layer decides. + await _vm.SetWriteTextAsync(text, number).ConfigureAwait(false); } } } diff --git a/WindowsPhone/RemoteAgents/RemoteAgents/ViewModel/ViewModel.cs b/WindowsPhone/RemoteAgents/RemoteAgents/ViewModel/ViewModel.cs index 3320499..788a762 100644 --- a/WindowsPhone/RemoteAgents/RemoteAgents/ViewModel/ViewModel.cs +++ b/WindowsPhone/RemoteAgents/RemoteAgents/ViewModel/ViewModel.cs @@ -11,12 +11,14 @@ namespace RemoteAgents.WindowsPhone.ViewModel async public Task GetCurrentDateAsync() { - return await _remoteClient.PostRemoteServiceAsync(uri, "getCurrentDate"); + // Returning data in a diferent context. Upper layer decides. + return await _remoteClient.PostRemoteServiceAsync(uri, "getCurrentDate").ConfigureAwait(false); } async public Task SetWriteTextAsync(string text, int number) { - await _remoteClient.PostRemoteServiceAsync(uriSetWriteText, "setWriteText", text, number); + // Returning data in a diferent context. Upper layer decides. + await _remoteClient.PostRemoteServiceAsync(uriSetWriteText, "setWriteText", text, number).ConfigureAwait(false); } }