@@ -12,7 +12,7 @@ namespace CodeHub.Core.ViewModels
1212{
1313 public static class ViewModelExtensions
1414 {
15- public static Task RequestModel < TRequest > ( this MvxViewModel viewModel , GitHubRequest < TRequest > request , bool forceDataRefresh , Action < GitHubResponse < TRequest > > update ) where TRequest : new ( )
15+ public static async Task RequestModel < TRequest > ( this MvxViewModel viewModel , GitHubRequest < TRequest > request , bool forceDataRefresh , Action < GitHubResponse < TRequest > > update ) where TRequest : new ( )
1616 {
1717 if ( forceDataRefresh )
1818 {
@@ -23,29 +23,16 @@ public static class ViewModelExtensions
2323 var application = Mvx . Resolve < IApplicationService > ( ) ;
2424 var uiThrad = Mvx . Resolve < IUIThreadService > ( ) ;
2525
26- return Task . Run ( async ( ) =>
27- {
28- var result = await application . Client . ExecuteAsync ( request ) . ConfigureAwait ( false ) ;
29- uiThrad . MarshalOnUIThread ( ( ) => update ( result ) ) ;
30-
31- if ( result . WasCached )
32- {
33- request . RequestFromCache = false ;
26+ var result = await application . Client . ExecuteAsync ( request ) . ConfigureAwait ( false ) ;
27+ uiThrad . MarshalOnUIThread ( ( ) => update ( result ) ) ;
3428
35- Task . Run ( async ( ) =>
36- {
37- try
38- {
39- var r = await application . Client . ExecuteAsync ( request ) . ConfigureAwait ( false ) ;
40- uiThrad . MarshalOnUIThread ( ( ) => update ( r ) ) ;
41- }
42- catch ( NotModifiedException )
43- {
44- System . Diagnostics . Debug . WriteLine ( "Not modified: " + request . Url ) ;
45- }
46- } ) . FireAndForget ( ) ;
47- }
48- } ) ;
29+ if ( result . WasCached )
30+ {
31+ request . RequestFromCache = false ;
32+ var uncachedTask = application . Client . ExecuteAsync ( request ) ;
33+ uncachedTask . FireAndForget ( ) ;
34+ uncachedTask . ContinueWith ( t => uiThrad . MarshalOnUIThread ( ( ) => update ( t . Result ) ) , TaskContinuationOptions . OnlyOnRanToCompletion ) ;
35+ }
4936 }
5037
5138 public static void CreateMore < T > ( this MvxViewModel viewModel , GitHubResponse < T > response ,
0 commit comments