diff --git a/Language/Language.cs b/Language/Language.cs index 98e41a5..011fed0 100644 --- a/Language/Language.cs +++ b/Language/Language.cs @@ -6,7 +6,7 @@ var wwwClient = new HttpClient(); -var assetsClientJSON = JsonSerializer.Deserialize(File.ReadAllBytes(Path.Combine(AppContext.BaseDirectory, "Assets", "Client.json")), new JsonSerializerOptions +var assetsClientJSON = JsonSerializer.Deserialize(await File.ReadAllBytesAsync(Path.Combine(AppContext.BaseDirectory, "Assets", "Client.json")), new JsonSerializerOptions { IncludeFields = true }); diff --git a/Qwilight/Compiler/BMSCompiler.cs b/Qwilight/Compiler/BMSCompiler.cs index 3148d78..6a96860 100644 --- a/Qwilight/Compiler/BMSCompiler.cs +++ b/Qwilight/Compiler/BMSCompiler.cs @@ -826,7 +826,7 @@ { var endStatus = parallelItems.Count; var status = 0; - Utility.HandleHMP(parallelItems, Configure.Instance.CompilingBin, parallelItem => + Utility.HandleLowlyParallelly(parallelItems, Configure.Instance.CompilingBin, parallelItem => { parallelItem(); defaultComputer.SetCompilingStatus((double)Interlocked.Increment(ref status) / endStatus); diff --git a/Qwilight/Compiler/BMSONCompiler.cs b/Qwilight/Compiler/BMSONCompiler.cs index 9427546..8d3d74f 100644 --- a/Qwilight/Compiler/BMSONCompiler.cs +++ b/Qwilight/Compiler/BMSONCompiler.cs @@ -577,7 +577,7 @@ { var endStatus = parallelItems.Count; var status = 0; - Utility.HandleHMP(parallelItems, Configure.Instance.CompilingBin, parallelItem => + Utility.HandleLowlyParallelly(parallelItems, Configure.Instance.CompilingBin, parallelItem => { parallelItem(); defaultComputer.SetCompilingStatus((double)Interlocked.Increment(ref status) / endStatus); diff --git a/Qwilight/Compiler/BaseCompiler.cs b/Qwilight/Compiler/BaseCompiler.cs index ac84f2e..6b83299 100644 --- a/Qwilight/Compiler/BaseCompiler.cs +++ b/Qwilight/Compiler/BaseCompiler.cs @@ -33,7 +33,7 @@ { NoteFile = noteFile; SetCancelCompiler = setCancelCompiler; - NoteFormatID = DB.Instance.GetFormat(noteFile); + NoteFormatID = Utility.Await(DB.Instance.GetFormat(noteFile)); } public abstract void CompileImpl(Computing targetComputing, byte[] noteFileContents, int salt); diff --git a/Qwilight/Compute/DefaultCompute.cs b/Qwilight/Compute/DefaultCompute.cs index 7af5f5b..bf50478 100644 --- a/Qwilight/Compute/DefaultCompute.cs +++ b/Qwilight/Compute/DefaultCompute.cs @@ -944,7 +944,7 @@ _targetHandler.Join(); } IsHandling = true; - _targetHandler = Utility.HandleLongParallel(HandleNotes); + _targetHandler = Utility.HandleParallelly(HandleNotes); } SendSituation(); }); @@ -1532,7 +1532,6 @@ _trapNoteJudgmentDate = Utility.IsLowerDate(date, 1, 14, 6) ? Component.TrapNoteJudgmentDate100 : Component.TrapNoteJudgmentDate1146; _paintEventsDate = Utility.IsLowerDate(date, 1, 14, 91) ? Component.PaintEventsDate100 : Component.PaintEventsDate11491; LongNoteModeDate = Utility.IsLowerDate(date, 1, 14, 20) ? Component.LongNoteMode100 : Utility.IsLowerDate(date, 1, 16, 4) ? Component.LongNoteMode11420 : Component.LongNoteMode1164; - NoteFile.SetConfigure(); Title = NoteFile.Title; Artist = NoteFile.Artist; Genre = NoteFile.Genre; @@ -1546,7 +1545,7 @@ _standModeDate = Utility.IsLowerDate(date, 1, 6, 7) ? Component.StandMode100 : Utility.IsLowerDate(date, 1, 14, 118) ? Component.StandMode167 : Component.StandMode114118; _tooLongLongNoteDate = Utility.IsLowerDate(date, 1, 13, 107) ? Component.TooLongLongNote100 : Utility.IsLowerDate(date, 1, 14, 20) ? Component.TooLongLongNote113107 : Utility.IsLowerDate(date, 1, 14, 29) ? Component.TooLongLongNote11420 : Component.TooLongLongNote11429; _targetCompiler = BaseCompiler.GetCompiler(NoteFile, _setCancelCompiler); - _targetCompilerHandler = Utility.GetLongParallel(() => _targetCompiler.Compile(this)); + _targetCompilerHandler = Utility.GetParallelHandler(() => _targetCompiler.Compile(this)); CommentWaitDate = Utility.IsLowerDate(date, 1, 3, 11) ? Component.CommentWaitDate100 : Utility.IsLowerDate(date, 1, 6, 4) ? Component.CommentWaitDate1311 : Component.CommentWaitDate164; HandleWarning(); } @@ -4565,7 +4564,7 @@ if (!_wasGetNetComments && _wasGetNetItems) { _wasGetNetComments = true; - Utility.HandleHMP(new ConcurrentBag(NetItems), QwilightComponent.CPUCount, async netItem => + Utility.HandleLowlyParallelly(new ConcurrentBag(NetItems), QwilightComponent.CPUCount, async netItem => { if (netItem.Comment == null) { diff --git a/Qwilight/NoteFile/BaseNoteFile.cs b/Qwilight/NoteFile/BaseNoteFile.cs index 81c2515..9474ae0 100644 --- a/Qwilight/NoteFile/BaseNoteFile.cs +++ b/Qwilight/NoteFile/BaseNoteFile.cs @@ -224,13 +224,13 @@ } } - public void SetConfigure() + public async Task SetConfigure() { - var (audioWait, mediaWait, media) = DB.Instance.GetWait(this); + var (audioWait, mediaWait, media) = await DB.Instance.GetWait(this); Configure.Instance.AudioWait = audioWait; Configure.Instance.MediaWait = mediaWait; Configure.Instance.Media = media != false; - Configure.Instance.NoteFormatID = DB.Instance.GetFormat(this); + Configure.Instance.NoteFormatID = await DB.Instance.GetFormat(this); } public virtual string GetNoteID128(byte[] data = null) diff --git a/Qwilight/System/BaseUI/BaseUI.cs b/Qwilight/System/BaseUI/BaseUI.cs index 5418937..61df69b 100644 --- a/Qwilight/System/BaseUI/BaseUI.cs +++ b/Qwilight/System/BaseUI/BaseUI.cs @@ -1542,7 +1542,7 @@ { MediaSystem.Instance.Stop(this); } - Utility.HandleHMP(parallelItems, Configure.Instance.UIBin, parallelItem => parallelItem()); + Utility.HandleLowlyParallelly(parallelItems, Configure.Instance.UIBin, parallelItem => parallelItem()); foreach (var paintPropertyValue in PaintPropertyValues) { diff --git a/Qwilight/System/Configure/Configure.cs b/Qwilight/System/Configure/Configure.cs index 3659c72..125ceb6 100644 --- a/Qwilight/System/Configure/Configure.cs +++ b/Qwilight/System/Configure/Configure.cs @@ -1497,6 +1497,16 @@ { OnPropertyChanged(nameof(MediaPaint)); OnPropertyChanged(nameof(MediaText)); + if (_isLoaded) + { + var handlingComputer = ViewModels.Instance.MainValue.GetHandlingComputer(); + if (handlingComputer != null) + { + handlingComputer.SetWait(); + MediaSystem.Instance.HandleDefaultIfAvailable(handlingComputer); + MediaSystem.Instance.HandleIfAvailable(handlingComputer); + } + } } } } diff --git a/Qwilight/System/DB.cs b/Qwilight/System/DB.cs index 36e8bf1..af44796 100644 --- a/Qwilight/System/DB.cs +++ b/Qwilight/System/DB.cs @@ -853,15 +853,15 @@ return rows.Read() ? (int)(long)rows["Note_Position"] : 0; } - public (double, double, bool?) GetWait(BaseNoteFile noteFile) + public async ValueTask<(double, double, bool?)> GetWait(BaseNoteFile noteFile) { using var dbStatement = new SQLiteCommand(@"SELECT Audio_Wait, Media_Wait, Media FROM wait WHERE Note_ID = @noteID", _db); dbStatement.Parameters.AddWithValue("noteID", noteFile.GetNoteID512()); - using var rows = dbStatement.ExecuteReader(); + using var rows = await dbStatement.ExecuteReaderAsync().ConfigureAwait(false); (double, double, bool?) data = (0.0, 0.0, default); - if (rows.Read()) + if (await rows.ReadAsync().ConfigureAwait(false)) { if (rows["Audio_Wait"] != DBNull.Value) { @@ -876,14 +876,14 @@ return data; } - public int GetFormat(BaseNoteFile noteFile) + public async Task GetFormat(BaseNoteFile noteFile) { using var dbStatement = new SQLiteCommand(@"SELECT Format FROM format WHERE Note_ID = @noteID", _db); dbStatement.Parameters.AddWithValue("noteID", noteFile.GetNoteID512()); - using var rows = dbStatement.ExecuteReader(); - return rows.Read() ? (int)(long)rows["Format"] : -1; + using var rows = await dbStatement.ExecuteReaderAsync().ConfigureAwait(false); + return await rows.ReadAsync().ConfigureAwait(false) ? (int)(long)rows["Format"] : -1; } public async Task SetNotePosition(EntryItem entryItem) diff --git a/Qwilight/System/DefaultControllerSystem/DInputSystem.cs b/Qwilight/System/DefaultControllerSystem/DInputSystem.cs index 9510b1a..7c89e98 100644 --- a/Qwilight/System/DefaultControllerSystem/DInputSystem.cs +++ b/Qwilight/System/DefaultControllerSystem/DInputSystem.cs @@ -15,7 +15,7 @@ public DInputSystem(IHandleInput handleInput) => _handleInput = handleInput; - public void HandleSystem(nint handle) => Utility.HandleLongParallel(() => + public void HandleSystem(nint handle) => Utility.HandleParallelly(() => { while (_isAvailable) { diff --git a/Qwilight/System/DefaultControllerSystem/DefaultSystem.cs b/Qwilight/System/DefaultControllerSystem/DefaultSystem.cs index aeae6c7..997ddbc 100644 --- a/Qwilight/System/DefaultControllerSystem/DefaultSystem.cs +++ b/Qwilight/System/DefaultControllerSystem/DefaultSystem.cs @@ -22,7 +22,7 @@ public DefaultSystem(IHandleInput handleInput) => _handleInput = handleInput; - public void HandleSystem() => Utility.HandleLongParallel(() => + public void HandleSystem() => Utility.HandleParallelly(() => { unsafe { diff --git a/Qwilight/System/LevelSystem.cs b/Qwilight/System/LevelSystem.cs index 7c970d1..99a4ddd 100644 --- a/Qwilight/System/LevelSystem.cs +++ b/Qwilight/System/LevelSystem.cs @@ -38,7 +38,7 @@ public void LoadLevelFiles() => Utility.SetUICollection(LevelFileNames, Utility.GetFiles(EntryPath).Where(levelFile => !Path.GetFileName(levelFile).StartsWith('#') && levelFile.IsTailCaselsss(".json")).Select(levelFile => Path.GetFileNameWithoutExtension(levelFile)).ToArray()); - public void LoadJSON(bool isNotify) + public async ValueTask LoadJSON(bool isNotify) { LevelID128s.Clear(); LevelID256s.Clear(); @@ -56,13 +56,15 @@ var levelTableFilePath = Path.Combine(QwilightComponent.QwilightEntryPath, "Level", $"#{levelName}.json"); if (File.Exists(levelTableFilePath)) { - var levelTable = Utility.GetJSON(File.ReadAllText(levelTableFilePath)); + using var tfs = File.OpenRead(levelTableFilePath); + var levelTable = await Utility.GetJSON(tfs); if (levelTable.HasValue) { var levelTableValue = levelTable.Value; var levelTexts = new List(); var levelTitle = levelTableValue.symbol; - foreach (var levelData in Utility.GetJSON(File.ReadAllText(levelFilePath))) + using var fs = File.OpenRead(levelFilePath); + foreach (var levelData in await Utility.GetJSON(fs)) { var level = levelData.level; var noteID128 = levelData.md5; @@ -115,7 +117,7 @@ using var s = await TwilightSystem.Instance.GetWwwParallel(WebUtility.HtmlDecode(ModifyDataValue(o.CreateNavigator().SelectSingleNode("/html/head/meta[@name='bmstable']/@content")?.ToString() ?? o.CreateNavigator().SelectSingleNode("/html/body/meta[@name='bmstable']/@content")?.ToString() ?? o.CreateNavigator().SelectSingleNode("/html/head/body/meta[@name='bmstable']/@content")?.ToString()))).ConfigureAwait(false); - var levelTable = Utility.GetJSON(s); + var levelTable = await Utility.GetJSON(s); s.Position = 0; if (levelTable.HasValue) { diff --git a/Qwilight/System/TelnetSystem/DefaultTelnetSystem.cs b/Qwilight/System/TelnetSystem/DefaultTelnetSystem.cs index e2ea08c..d589990 100644 --- a/Qwilight/System/TelnetSystem/DefaultTelnetSystem.cs +++ b/Qwilight/System/TelnetSystem/DefaultTelnetSystem.cs @@ -23,7 +23,7 @@ _handleTelnet = handleTelnet; } - public void HandleSystem() => Utility.HandleLongParallel(() => + public void HandleSystem() => Utility.HandleParallelly(() => { while (_isAvailable) { @@ -136,7 +136,7 @@ Contents = new Action(fileName => { ViewModels.Instance.MainValue.ModeComponentValue.Salt = 0; - Utility.HandleHMP(new ConcurrentBag(ViewModels.Instance.MainValue.EntryItems.SelectMany(entryItem => entryItem.WellNoteFiles.Where(noteFile => !noteFile.IsLogical))), Configure.Instance.UIBin, noteFile => + Utility.HandleLowlyParallelly(new ConcurrentBag(ViewModels.Instance.MainValue.EntryItems.SelectMany(entryItem => entryItem.WellNoteFiles.Where(noteFile => !noteFile.IsLogical))), Configure.Instance.UIBin, noteFile => { Console.WriteLine(noteFile.NoteFilePath); var targetCompiler = BaseCompiler.GetCompiler(noteFile, null); diff --git a/Qwilight/System/TwilightSystem.cs b/Qwilight/System/TwilightSystem.cs index 64ce574..b2b8862 100644 --- a/Qwilight/System/TwilightSystem.cs +++ b/Qwilight/System/TwilightSystem.cs @@ -936,7 +936,7 @@ var saveDataFlow = savedBundleItem.SaveDataFlow; eventItemData[0].WriteTo(saveDataFlow); saveDataFlow.Position = 0; - Utility.HandleLongParallel(() => + Utility.HandleParallelly(() => { var bundleVariety = (BundleItem.BundleVariety)twilightSavedBundle.bundleVariety; var isNotDefaultBundle = bundleVariety != BundleItem.BundleVariety.DefaultNotes && bundleVariety != BundleItem.BundleVariety.DefaultUI; diff --git a/Qwilight/System/UI/UI.cs b/Qwilight/System/UI/UI.cs index dbd1035..c3527aa 100644 --- a/Qwilight/System/UI/UI.cs +++ b/Qwilight/System/UI/UI.cs @@ -1496,7 +1496,7 @@ AudioSystem.Instance.Close(this); DrawingSystem.Instance.Close(this); } - Utility.HandleHMP(parallelItems, Configure.Instance.UIBin, parallelItem => parallelItem()); + Utility.HandleLowlyParallelly(parallelItems, Configure.Instance.UIBin, parallelItem => parallelItem()); foreach (var fileName in audioValues.Keys) { diff --git a/Qwilight/Utilities/AwaitUtility.cs b/Qwilight/Utilities/AwaitUtility.cs index d4c542d..c9bbb53 100644 --- a/Qwilight/Utilities/AwaitUtility.cs +++ b/Qwilight/Utilities/AwaitUtility.cs @@ -4,9 +4,13 @@ { public static partial class Utility { - public static T Await(IAsyncOperation awaitable) + public static T Await(IAsyncOperation t) { - using var t = awaitable.AsTask(); + return Await(t); + } + + public static T Await(Task t) + { t.Wait(); return t.Result; } diff --git a/Qwilight/Utilities/JSONUtility.cs b/Qwilight/Utilities/JSONUtility.cs index 2ac330a..dc417c2 100644 --- a/Qwilight/Utilities/JSONUtility.cs +++ b/Qwilight/Utilities/JSONUtility.cs @@ -40,7 +40,7 @@ public static T GetJSON(byte[] data) => JsonSerializer.Deserialize(data, _defaultGetJSONConfigure); - public static T GetJSON(Stream s) => JsonSerializer.Deserialize(s, _defaultGetJSONConfigure); + public static async ValueTask GetJSON(Stream s) => await JsonSerializer.DeserializeAsync(s, _defaultGetJSONConfigure); public static string SetJSON(T data, JsonSerializerOptions defaultJSONConfigure = null) => JsonSerializer.Serialize(data, defaultJSONConfigure ?? _defaultSetJSONConfigure); } diff --git a/Qwilight/Utilities/ParallelUtility.cs b/Qwilight/Utilities/ParallelUtility.cs index fe5e468..feb8a9e 100644 --- a/Qwilight/Utilities/ParallelUtility.cs +++ b/Qwilight/Utilities/ParallelUtility.cs @@ -4,20 +4,20 @@ { public static partial class Utility { - public static Thread GetLongParallel(ThreadStart onHandle, bool isEssential = true) => new Thread(onHandle) + public static Thread GetParallelHandler(ThreadStart onHandle, bool isEssential = true) => new Thread(onHandle) { IsBackground = true, Priority = isEssential ? ThreadPriority.Highest : ThreadPriority.Normal }; - public static Thread HandleLongParallel(ThreadStart onHandle, bool isEssential = true) + public static Thread HandleParallelly(ThreadStart onHandle, bool isEssential = true) { - var t = GetLongParallel(onHandle, isEssential); + var t = GetParallelHandler(onHandle, isEssential); t.Start(); return t; } - public static void HandleHMP(IProducerConsumerCollection parallelItems, int onHandleBin, Action onHandle, CancellationToken? setCancelParallel = null) + public static void HandleLowlyParallelly(IProducerConsumerCollection parallelItems, int onHandleBin, Action onHandle, CancellationToken? setCancelParallel = null) { var longParallels = new Thread[onHandleBin]; for (var i = longParallels.Length - 1; i >= 0; --i) diff --git a/Qwilight/View/LevelWindow.xaml.cs b/Qwilight/View/LevelWindow.xaml.cs index 7b153bd..a56d3d6 100644 --- a/Qwilight/View/LevelWindow.xaml.cs +++ b/Qwilight/View/LevelWindow.xaml.cs @@ -10,6 +10,6 @@ void OnInput(object sender, RoutedEventArgs e) => (DataContext as LevelViewModel).OnInput(); - void OnNewLevel(object sender, SelectionChangedEventArgs e) => (DataContext as LevelViewModel).OnNewLevel(); + void OnNewLevel(object sender, SelectionChangedEventArgs e) => _ = (DataContext as LevelViewModel).OnNewLevel(); } } \ No newline at end of file diff --git a/Qwilight/ViewModel/ConfigureViewModel.cs b/Qwilight/ViewModel/ConfigureViewModel.cs index 3cfa562..2daf3d4 100644 --- a/Qwilight/ViewModel/ConfigureViewModel.cs +++ b/Qwilight/ViewModel/ConfigureViewModel.cs @@ -614,13 +614,6 @@ if (r == MESSAGEBOX_RESULT.IDYES) { Configure.Instance.Media = true; - var handlingComputer = ViewModels.Instance.MainValue.GetHandlingComputer(); - if (handlingComputer != null) - { - handlingComputer.SetWait(); - MediaSystem.Instance.HandleDefaultIfAvailable(handlingComputer); - MediaSystem.Instance.HandleIfAvailable(handlingComputer); - } await DB.Instance.InitMedia().ConfigureAwait(false); NotifySystem.Instance.Notify(NotifySystem.NotifyVariety.OK, NotifySystem.NotifyConfigure.Default, LanguageSystem.Instance.InitMediaOK); } @@ -795,17 +788,7 @@ static void OnGetWaveValues() => AudioInputSystem.Instance.GetWaveValues(); [RelayCommand] - static void OnMedia() - { - Configure.Instance.Media = !Configure.Instance.Media; - var handlingComputer = ViewModels.Instance.MainValue.GetHandlingComputer(); - if (handlingComputer != null) - { - handlingComputer.SetWait(); - MediaSystem.Instance.HandleDefaultIfAvailable(handlingComputer); - MediaSystem.Instance.HandleIfAvailable(handlingComputer); - } - } + static void OnMedia() => Configure.Instance.Media = !Configure.Instance.Media; [RelayCommand] static void OnHandleInputAudio() => Configure.Instance.HandleInputAudio = !Configure.Instance.HandleInputAudio; diff --git a/Qwilight/ViewModel/LevelViewModel.cs b/Qwilight/ViewModel/LevelViewModel.cs index e701006..d53a2ff 100644 --- a/Qwilight/ViewModel/LevelViewModel.cs +++ b/Qwilight/ViewModel/LevelViewModel.cs @@ -34,11 +34,11 @@ OnPropertyChanged(nameof(IsTotalWantLevel)); } - public void OnNewLevel() + public async Task OnNewLevel() { if (IsLoaded) { - LevelSystem.Instance.LoadJSON(true); + await LevelSystem.Instance.LoadJSON(true); Configure.Instance.WantLevelIDs = LevelSystem.Instance.LevelCollection.ToArray(); SetLevelItemCollection(); } @@ -74,7 +74,7 @@ if (!string.IsNullOrEmpty(levelInput)) { await LevelSystem.Instance.LoadWww(levelInput).ConfigureAwait(false); - LevelSystem.Instance.LoadJSON(true); + await LevelSystem.Instance.LoadJSON(true); } }) } @@ -83,7 +83,7 @@ else { await LevelSystem.Instance.LoadWww(www).ConfigureAwait(false); - LevelSystem.Instance.LoadJSON(true); + await LevelSystem.Instance.LoadJSON(true); } } @@ -93,7 +93,7 @@ if (Configure.Instance.LevelTargetMap.TryGetValue(Configure.Instance.WantLevelName, out var target)) { await LevelSystem.Instance.LoadWww(target).ConfigureAwait(false); - LevelSystem.Instance.LoadJSON(true); + await LevelSystem.Instance.LoadJSON(true); } else { diff --git a/Qwilight/ViewModel/MainViewModel.cs b/Qwilight/ViewModel/MainViewModel.cs index 4bef658..1f9497f 100644 --- a/Qwilight/ViewModel/MainViewModel.cs +++ b/Qwilight/ViewModel/MainViewModel.cs @@ -555,7 +555,7 @@ DrawingSystem.Instance.LoadDefaultDrawing(); DrawingSystem.Instance.LoadVeilDrawing(); - LevelSystem.Instance.LoadJSON(false); + await LevelSystem.Instance.LoadJSON(false); await ValveSystem.Instance.Init().ConfigureAwait(false); await Task.Run(() => @@ -566,14 +566,14 @@ _isLoaded = true; - Utility.HandleLongParallel(TVSystem.Instance.HandleSystem, false); - Utility.HandleLongParallel(IlluminationSystem.Instance.HandleSystem, false); + Utility.HandleParallelly(TVSystem.Instance.HandleSystem, false); + Utility.HandleParallelly(IlluminationSystem.Instance.HandleSystem, false); DefaultControllerSystem.Instance.HandleSystem(); - Utility.HandleLongParallel(DrawingSystem.Instance.HandleSystem); - Utility.HandleLongParallel(TwilightSystem.Instance.HandleSystem, false); - Utility.HandleLongParallel(PlatformSystem.Instance.HandleSystem, false); - Utility.HandleLongParallel(FlintSystem.Instance.HandleSystem, false); - Utility.HandleLongParallel(() => ControllerSystem.Instance.HandleSystem(handle)); + Utility.HandleParallelly(DrawingSystem.Instance.HandleSystem); + Utility.HandleParallelly(TwilightSystem.Instance.HandleSystem, false); + Utility.HandleParallelly(PlatformSystem.Instance.HandleSystem, false); + Utility.HandleParallelly(FlintSystem.Instance.HandleSystem, false); + Utility.HandleParallelly(() => ControllerSystem.Instance.HandleSystem(handle)); if (Configure.Instance.AudioMultiplierAtone) { @@ -1290,13 +1290,13 @@ } [RelayCommand] - void OnViewAssistFile() + async Task OnViewAssistFile() { var noteFile = EntryItemValue.NoteFile; var assistFilePath = Path.Combine(noteFile.EntryItem.EntryPath, noteFile.AssistFileName); if (File.Exists(assistFilePath)) { - var format = DB.Instance.GetFormat(noteFile); + var format = await DB.Instance.GetFormat(noteFile); if (format == -1) { var formatComputer = CharsetDetector.DetectFromFile(assistFilePath).Detected; @@ -1304,7 +1304,7 @@ } var assistFileViewModel = ViewModels.Instance.AssistFileValue; assistFileViewModel.Title = noteFile.EntryItem.Title; - assistFileViewModel.Assist = File.ReadAllText(assistFilePath, Encoding.GetEncoding(format)); + assistFileViewModel.Assist = await File.ReadAllTextAsync(assistFilePath, Encoding.GetEncoding(format)); assistFileViewModel.Open(); } } @@ -1883,7 +1883,7 @@ FastDB.Instance.WipeEntryItem(entryPath); } } - Utility.HandleHMP(entryPaths, Configure.Instance.LoadingBin, entryPath => + Utility.HandleLowlyParallelly(entryPaths, Configure.Instance.LoadingBin, entryPath => { LoadEntryItem(defaultEntryItem, entryPath, _setCancelDefaultEntryItem); Status = (double)Interlocked.Increment(ref status) / endStatus; @@ -2548,13 +2548,6 @@ if (HasNotInput()) { Configure.Instance.Media = !Configure.Instance.Media; - var handlingComputer = GetHandlingComputer(); - if (handlingComputer != null) - { - handlingComputer.SetWait(); - MediaSystem.Instance.HandleDefaultIfAvailable(handlingComputer); - MediaSystem.Instance.HandleIfAvailable(handlingComputer); - } } } @@ -3430,13 +3423,14 @@ void HandleImpl() { - (AutoComputer ?? Computer)?.Migrate(targetComputer); var defaultComputer = Computer; + (AutoComputer ?? defaultComputer)?.Migrate(targetComputer); Computer = targetComputer; Computer.HandleCompiler(); ModeValue = Mode.Computing; defaultComputer?.Close(); CloseAutoComputer(); + _ = targetComputer.NoteFile.SetConfigure(); } } @@ -3537,7 +3531,7 @@ else { CloseAutoComputer("Default"); - targetNoteFile.SetConfigure(); + _ = targetNoteFile.SetConfigure(); } void NewAutoComputer(double levyingWait, bool doMigrate) diff --git a/Test/Test.csproj b/Test/Test.csproj index 6adbe11..bc4be69 100644 --- a/Test/Test.csproj +++ b/Test/Test.csproj @@ -7,6 +7,7 @@ true x64;ARM64 true + true