private void T_Elapsed(object sender, ElapsedEventArgs e) { ((Timer)sender).Stop(); context.InvokeOnMainThread(() => { RefitImagesContainer(); }); }
public async Task UploadFile(string fileName, string regsessionid) //use Task<int> for return value { imagesUploading = true; context.InvokeOnMainThread(() => { StartAnim(); }); try { string url; if (c.IsLoggedIn()) { url = Constants.HostName + "?action=uploadtouser&ID=" + Session.ID + "&SessionID=" + Session.SessionID; if (Constants.isTestDB) { url += Constants.TestDB; } } else { url = (regsessionid == "") ? Constants.HostName + "?action=uploadtotemp" : Constants.HostName + "?action=uploadtotemp®sessionid=" + regsessionid; if (Constants.isTestDB) { url += Constants.TestDB; } } await client.UploadFileTaskAsync(url, fileName); } catch (WebException ex) { //Client_UploadFileCompleted is called too which resets the views if (((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.InternalServerError) //issue on Android, but not here as iOS resizes uploaded pictures to a max dimension of 2048 px, and stock & camera photos also do not exceed 16 M { c.ErrorAlert(LangEnglish.OutOfMemory); } else { c.ReportErrorSilent("Upload image error: " + ((HttpWebResponse)ex.Response).StatusCode + " " + ex.Message + System.Environment.NewLine + ex.StackTrace); } } }