Created
October 4, 2014 19:57
-
-
Save paulbatum/638015245b48171cd434 to your computer and use it in GitHub Desktop.
NetworkActivityHandler
This file contains 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
public class NetworkActivityHandler : DelegatingHandler | |
{ | |
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) | |
{ | |
using (new NetworkActivityDisposable()) | |
{ | |
return base.SendAsync(request, cancellationToken); | |
} | |
} | |
private class NetworkActivityDisposable : IDisposable | |
{ | |
public NetworkActivityDisposable() | |
{ | |
#if __IOS__ | |
MonoTouch.UIKit.UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true; | |
#endif | |
} | |
public void Dispose() | |
{ | |
#if __IOS__ | |
MonoTouch.UIKit.UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false; | |
#endif | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment