1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-28 06:12:54 +08:00

Merge pull request #1429 from peppy/fix-direct-import-stall

Fix import after direct download being scheduled to update thread
This commit is contained in:
Dean Herbert 2017-10-25 22:03:27 +09:00 committed by GitHub
commit 5cd04392b4
3 changed files with 14 additions and 7 deletions

View File

@ -106,7 +106,7 @@ namespace osu.Desktop
var filePaths = new [] { e.FileName };
if (filePaths.All(f => Path.GetExtension(f) == @".osz"))
Task.Run(() => BeatmapManager.Import(filePaths));
Task.Factory.StartNew(() => BeatmapManager.Import(filePaths), TaskCreationOptions.LongRunning);
else if (filePaths.All(f => Path.GetExtension(f) == @".osr"))
Task.Run(() =>
{

View File

@ -244,11 +244,17 @@ namespace osu.Game.Beatmaps
request.Success += data =>
{
downloadNotification.State = ProgressNotificationState.Completed;
downloadNotification.Text = $"Importing {beatmapSetInfo.Metadata.Artist} - {beatmapSetInfo.Metadata.Title}";
using (var stream = new MemoryStream(data))
using (var archive = new OszArchiveReader(stream))
Import(archive);
Task.Factory.StartNew(() =>
{
// This gets scheduled back to the update thread, but we want the import to run in the background.
using (var stream = new MemoryStream(data))
using (var archive = new OszArchiveReader(stream))
Import(archive);
downloadNotification.State = ProgressNotificationState.Completed;
}, TaskCreationOptions.LongRunning);
currentDownloads.Remove(request);
};
@ -272,7 +278,7 @@ namespace osu.Game.Beatmaps
PostNotification?.Invoke(downloadNotification);
// don't run in the main api queue as this is a long-running task.
Task.Run(() => request.Perform(api));
Task.Factory.StartNew(() => request.Perform(api), TaskCreationOptions.LongRunning);
return request;
}

View File

@ -29,7 +29,8 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
Action = () =>
{
importButton.Enabled.Value = false;
Task.Run(() => beatmaps.ImportFromStable()).ContinueWith(t => Schedule(() => importButton.Enabled.Value = true));
Task.Factory.StartNew(beatmaps.ImportFromStable)
.ContinueWith(t => Schedule(() => importButton.Enabled.Value = true), TaskContinuationOptions.LongRunning);
}
},
deleteButton = new SettingsButton