protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); mStocks = new List<Stock>(); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it if(mButton == null) mButton = FindViewById<Button>(Resource.Id.MyButton); mButton.Click += delegate { if (!mIsFetching) { mIsFetching = true; mButton.Text = "Downloading Stocks..."; var fetcher = new StockFetcher(); fetcher.OnDownloadComplete += (sender, e) => { mButton.Text = "Download Complete"; Console.WriteLine("Download Complete"); }; fetcher.OnProgressChanged += (sender, progress) => { mButton.Text = string.Format("{0:p} Complete", progress); Console.WriteLine(string.Format("{0:p}")); }; Task.Run(() => { mStocks = fetcher.GetStocks().Result; }); } }; }
private DataController(string stockServerUri) { StockFetcher.CreateStockFetcher(stockServerUri); fetcher = StockFetcher.Instance; }