public void Dispose() { if (package != null) { package.Dispose(); package = null; } }
protected override void OnClosing(CancelEventArgs e) { if (buttonSubmit.Enabled && !hasPostedToForum) { buttonSubmit_Click(this, null); e.Cancel = true; return; } editor.SubmissionComplete(); formClosing = true; if (activeWebRequest != null) { activeWebRequest.Abort(); } if (backgroundWorker != null) { backgroundWorker.CancelAsync(); } base.OnClosing(e); GameBase.MenuActive = false; BanchoClient.UpdateStatus(bStatus.Editing); if (packagePreviousUpload != null) { packagePreviousUpload.Dispose(); } if (packageCurrentUpload != null) { packageCurrentUpload.Dispose(); } GameBase.Form.Focus(); }
private void submission_PackageAndUpload_Complete(pWebRequest r, Exception e) { backgroundWorker.DoWork -= submission_PackageAndUpload; string result = r == null ? "-1" : r.ResponseString; Debug.Print(result); if (uploadError || e != null || result != "0") { Invoke(delegate { if (!string.IsNullOrEmpty(result)) { handleErrorCode(result.Split('\n'), 1); } else { result = null; } if (!formClosing) { string errorDetails = error ?? result ?? (e != null ? Logger.ApplyFilters(e.Message) : "No response from the server"); string errorMessage = string.Format(LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_ErrorDuringUpload), errorDetails).Trim('\n', ' '); MessageBox.Show(this, errorMessage, "osu!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } Close(); }); if (packageCurrentUpload != null) { packageCurrentUpload.Dispose(); File.Delete(packageCurrentUpload.Filename); packageCurrentUpload = null; } return; } //Replace/create submissionCache for this map... try { packageCurrentUpload.Close(); string lastUpload = lastUploadFilename; if (!Directory.Exists(Path.GetDirectoryName(lastUpload))) { Directory.CreateDirectory(Path.GetDirectoryName(lastUpload)); } if (packagePreviousUpload != null) { packagePreviousUpload.Close(); } File.Delete(lastUpload); File.Move(packageCurrentUpload.Filename, lastUpload); } catch { } //Finished uploading. Alert the user! UpdateStatus(isNewSubmission ? LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_Uploaded) : LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_Updated)); Invoke(delegate { if (!formClosing) { progressBar1.Value = 100; } buttonSubmit.Enabled = true; buttonCancel.Enabled = false; AudioEngine.PlaySample(@"notify1"); GameBase.FlashWindow(Handle, false); }); }