mirror of
https://github.com/ppy/osu.git
synced 2025-02-28 17:02:55 +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:
commit
5cd04392b4
@ -106,7 +106,7 @@ namespace osu.Desktop
|
|||||||
var filePaths = new [] { e.FileName };
|
var filePaths = new [] { e.FileName };
|
||||||
|
|
||||||
if (filePaths.All(f => Path.GetExtension(f) == @".osz"))
|
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"))
|
else if (filePaths.All(f => Path.GetExtension(f) == @".osr"))
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
@ -244,12 +244,18 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
request.Success += data =>
|
request.Success += data =>
|
||||||
{
|
{
|
||||||
downloadNotification.State = ProgressNotificationState.Completed;
|
downloadNotification.Text = $"Importing {beatmapSetInfo.Metadata.Artist} - {beatmapSetInfo.Metadata.Title}";
|
||||||
|
|
||||||
|
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 stream = new MemoryStream(data))
|
||||||
using (var archive = new OszArchiveReader(stream))
|
using (var archive = new OszArchiveReader(stream))
|
||||||
Import(archive);
|
Import(archive);
|
||||||
|
|
||||||
|
downloadNotification.State = ProgressNotificationState.Completed;
|
||||||
|
}, TaskCreationOptions.LongRunning);
|
||||||
|
|
||||||
currentDownloads.Remove(request);
|
currentDownloads.Remove(request);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -272,7 +278,7 @@ namespace osu.Game.Beatmaps
|
|||||||
PostNotification?.Invoke(downloadNotification);
|
PostNotification?.Invoke(downloadNotification);
|
||||||
|
|
||||||
// don't run in the main api queue as this is a long-running task.
|
// 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;
|
return request;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,8 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
|||||||
Action = () =>
|
Action = () =>
|
||||||
{
|
{
|
||||||
importButton.Enabled.Value = false;
|
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
|
deleteButton = new SettingsButton
|
||||||
|
Loading…
Reference in New Issue
Block a user