性能优化

This commit is contained in:
ZouJin 2023-08-16 13:09:32 +10:00
parent f986bf907f
commit cc1e18735f
4 changed files with 10 additions and 10 deletions

View File

@ -65,7 +65,7 @@ namespace VPet_Simulator.Core
/// <param name="img">用于显示的Image</param> /// <param name="img">用于显示的Image</param>
/// <param name="EndAction">结束动画</param> /// <param name="EndAction">结束动画</param>
/// <returns>准备好的线程</returns> /// <returns>准备好的线程</returns>
public static Thread Run(this IGraph graph, Image img, Action EndAction = null) public static Task Run(this IGraph graph, Image img, Action EndAction = null)
{ {
if (graph is IImageRun iri) if (graph is IImageRun iri)
{ {

View File

@ -332,7 +332,7 @@ namespace VPet_Simulator.Core
{ {
if (parant.Tag == this) if (parant.Tag == this)
{ {
new Thread(() => Animations[0].Run((System.Windows.Controls.Image)parant.Child, EndAction)).Start(); Task.Run(() => Animations[0].Run((System.Windows.Controls.Image)parant.Child, EndAction));
return; return;
} }
System.Windows.Controls.Image img; System.Windows.Controls.Image img;
@ -378,7 +378,7 @@ namespace VPet_Simulator.Core
/// <param name="img">用于显示的Image</param> /// <param name="img">用于显示的Image</param>
/// <param name="EndAction">结束动画</param> /// <param name="EndAction">结束动画</param>
/// <returns>准备好的线程</returns> /// <returns>准备好的线程</returns>
public Thread Run(System.Windows.Controls.Image img, Action EndAction = null) public Task Run(System.Windows.Controls.Image img, Action EndAction = null)
{ {
nowid = 0; nowid = 0;
PlayState = true; PlayState = true;
@ -387,12 +387,12 @@ namespace VPet_Simulator.Core
{ {
if (img.Tag == this) if (img.Tag == this)
{ {
return new Thread(() => Animations[0].Run(img, EndAction)); return new Task(() => Animations[0].Run(img, EndAction));
} }
img.Tag = this; img.Tag = this;
img.Source = new BitmapImage(new Uri(Path)); img.Source = new BitmapImage(new Uri(Path));
img.Width = Width; img.Width = Width;
return new Thread(() => Animations[0].Run(img, EndAction)); return new Task(() => Animations[0].Run(img, EndAction));
}); });
} }
public void Stop(bool StopEndAction = false) public void Stop(bool StopEndAction = false)

View File

@ -139,7 +139,7 @@ namespace VPet_Simulator.Core
PlayState = false; PlayState = false;
this.DoEndAction = !StopEndAction; this.DoEndAction = !StopEndAction;
} }
public Thread Run(System.Windows.Controls.Image img, Action EndAction = null) public Task Run(System.Windows.Controls.Image img, Action EndAction = null)
{ {
PlayState = true; PlayState = true;
DoEndAction = true; DoEndAction = true;
@ -147,7 +147,7 @@ namespace VPet_Simulator.Core
{ {
if (img.Tag == this) if (img.Tag == this)
{ {
return new Thread(() => return new Task(() =>
{ {
Thread.Sleep(Length); Thread.Sleep(Length);
if (IsLoop && PlayState) if (IsLoop && PlayState)
@ -165,7 +165,7 @@ namespace VPet_Simulator.Core
img.Tag = this; img.Tag = this;
img.Source = new BitmapImage(new Uri(Path)); img.Source = new BitmapImage(new Uri(Path));
img.Width = 500; img.Width = 500;
return new Thread(() => return new Task(() =>
{ {
Thread.Sleep(Length); Thread.Sleep(Length);
if (IsLoop && PlayState) if (IsLoop && PlayState)
@ -189,7 +189,7 @@ namespace VPet_Simulator.Core
/// <param name="img">用于显示的Image</param> /// <param name="img">用于显示的Image</param>
/// <param name="EndAction">结束动画</param> /// <param name="EndAction">结束动画</param>
/// <returns>准备好的线程</returns> /// <returns>准备好的线程</returns>
Thread Run(System.Windows.Controls.Image img, Action EndAction = null); Task Run(System.Windows.Controls.Image img, Action EndAction = null);
} }
} }

View File

@ -667,7 +667,7 @@ namespace VPet_Simulator.Windows
private void Group_Click(object sender, RoutedEventArgs e) private void Group_Click(object sender, RoutedEventArgs e)
{ {
if (LocalizeCore.CurrentCulture.StartsWith("zh")) if (LocalizeCore.CurrentCulture.StartsWith("zh"))
ExtensionSetting.StartURL("https://jq.qq.com/?_wv=1027&k=zmeWNHyI"); ExtensionSetting.StartURL("https://tieba.baidu.com/f?kw=%E8%99%9A%E6%8B%9F%E4%B8%BB%E6%92%AD%E6%A8%A1%E6%8B%9F%E5%99%A8");
else else
ExtensionSetting.StartURL("https://github.com/LorisYounger/VPet"); ExtensionSetting.StartURL("https://github.com/LorisYounger/VPet");
} }