public void Dispose() { try { CompositionTarget.Rendering -= OnRender; this.LoadedFile = null; } catch { } }
void ContinueLoading() { if (loading) { return; } loading = true; Keyboard.ClearFocus(); loadSettingsScreen.Visibility = Visibility.Collapsed; loadProgessScreen.Visibility = Visibility.Visible; LoadedFile = new MIDIMemoryFile(filepath, loaderSettings, cancel.Token); LoadedFile.ParseFinished += () => { Dispatcher.InvokeAsync(() => { ParseFinished?.Invoke(); }).Task.GetAwaiter().GetResult(); }; LoadedFile.ParseCancelled += () => { Dispose(); Dispatcher.InvokeAsync(() => { ParseCancelled?.Invoke(); }).Task.GetAwaiter().GetResult(); }; Task.Run(() => { try { LoadedFile.Parse(); } catch (Exception e) { Dispatcher.InvokeAsync(() => { MessageBox.Show(e.Message, "Couldn't load midi file", this); ParseCancelled?.Invoke(); }).Task.GetAwaiter().GetResult(); } }); rotateStoryboard.Children.Add(rotate); Storyboard.SetTarget(rotate, rotateLogo); Storyboard.SetTargetProperty(rotate, new PropertyPath("(Image.RenderTransform).(RotateTransform.Angle)")); CompositionTarget.Rendering += OnRender; }