using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Threading;
namespace RecCore.Main.Controls.Loading
{
public class LoadingHelper
{
private static LoadingCtl loadingCtl;
public static void ShowLoading()
{
Thread thread = new Thread(new ThreadStart(ShowWPF));
thread.IsBackground = true;
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
///
/// 开启loading
///
private static void ShowWPF()
{
if (loadingCtl != null)
{
loadingCtl.Close();
loadingCtl = null;
}
loadingCtl = new LoadingCtl();
loadingCtl.Topmost = true;
loadingCtl.ShowDialog();
}
///
/// 关闭loading
///
public static void CloseLoading()
{
Thread.Sleep(50);
if (loadingCtl != null)
{
Thread.Sleep(50);
if (loadingCtl != null)
{
Thread.Sleep(50);
loadingCtl.Dispatcher.InvokeAsync(() =>
{
loadingCtl.Close();
loadingCtl = null;
});
}
}
}
}
}