[MonoTouch] NetworkActivityIndicatorVisible with MonoTouch.Dialog
cbailey
curtis at smartjobsapp.com
Fri Mar 2 19:25:54 UTC 2012
I have NetworkActivityIndicatorVisible using MonoTouch.Dialog working in my
projects. I think your problem has nothing to do with MonoTouch.Dialog. I
think you need to put your login code on a new thread so that it doesn't
lock up the UI thread. Try something like the following. Haven't tested it
but you get the idea.
StyledStringElement btnLogin = new StyledStringElement("Login", delegate {
LoginAsync(); });
public void LoginAsync()
{
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
// Start long runing operation on new thread so we don't lock up the UI.
Thread thread = new Thread(new ThreadStart(BeginLogin));
thread.Start();
}
private void BeginLogin()
{
try
{
// Load data from internet here.
}
finally
{
// Invoke on main thread if EndLogin updates UI.
InvokeOnMainThread(EndLogin);
}
}
private void EndLogin()
{
// Update UI here is OK because EndLogin will be InvokeOnMainThread.
// Reset NetworkActivityIndicatorVisible.
UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
}
--
View this message in context: http://monotouch.2284126.n4.nabble.com/NetworkActivityIndicatorVisible-with-MonoTouch-Dialog-tp4439142p4439556.html
Sent from the MonoTouch mailing list archive at Nabble.com.
More information about the MonoTouch
mailing list