void Initialize() { flowView = new OpenFlowView (UIScreen.MainScreen.Bounds, this); View = flowView; using (var alertView = new UIAlertView ("OpenFlowSharp Demo Data Source", "Would you like to download images from Flickr or use 30 sample images included with this project?", null, "Flickr", "Samples (all at once)", "Samples (using threads)")){ alertView.Dismissed += delegate(object sender, UIButtonEventArgs e) { switch (e.ButtonIndex){ // Flickr case 0: flickr = new Flickr (apiKey, sharedSecret); tasks.Enqueue (delegate { try { Network = true; photos = flickr.InterestingnessGetList (); Network = false; InvokeOnMainThread (delegate { flowView.NumberOfImages = photos.Count; }); } catch { InvokeOnMainThread (delegate { using (var alert = new UIAlertView ("Error", "While accessing Flickr", null, "Ok")){ alert.Show (); } }); } }); break; // Load images on demand on a worker thread case 2: flowView.NumberOfImages = 30; break; // Sync case, load all images at startup case 1: LoadAllImages (); return; } // Start our thread queue system new Thread (Worker).Start (); signal.Set (); }; alertView.Show (); } }