You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LoadingHelper.cs

88 lines
2.3 KiB
C#

using Mesnac.Action.ChemicalWeighing.FreeDb;
using System;
1 year ago
using System.Threading;
namespace Mesnac.Action.ChemicalWeighing
{
public class LoadingHelper
1 year ago
{
#region 相关变量定义
/// <summary>
/// 定义委托进行窗口关闭
/// </summary>
private delegate void CloseDelegate();
private static Loading loading;
1 year ago
private static readonly Object syncLock = new Object(); //加锁使用
1 year ago
#endregion
//private LoadingHelper()
//{
//}
1 year ago
/// <summary>
/// 显示loading框
/// </summary>
11 months ago
//public static void ShowLoadingScreen()
//{
// // Make sure it is only launched once.
// if (loading != null)
// return;
// Thread thread = new Thread(new ThreadStart(LoadingHelper.ShowForm));
// thread.IsBackground = true;
// thread.SetApartmentState(ApartmentState.STA);
// thread.Start();
11 months ago
//}
1 year ago
/// <summary>
/// 显示窗口
/// </summary>
private static void ShowForm()
{
if (loading != null)
1 year ago
{
loading.closeOrder();
loading = null;
1 year ago
}
loading = new Loading();
loading.TopMost = true;
loading.ShowDialog();
1 year ago
}
1 year ago
/// <summary>
/// 关闭窗口
/// </summary>
11 months ago
//public static void CloseForm()
//{
// Thread.Sleep(50); //可能到这里线程还未起来,所以进行延时,可以确保线程起来,彻底关闭窗口
// if (loading != null)
// {
// lock (syncLock)
// {
// Thread.Sleep(50);
// if (loading != null)
// {
// Thread.Sleep(50); //通过三次延时,确保可以彻底关闭窗口
// loading.Invoke(new CloseDelegate(LoadingHelper.CloseFormInternal));
// }
// }
// }
//}
1 year ago
/// <summary>
/// 关闭窗口,委托中使用
/// </summary>
private static void CloseFormInternal()
{
loading.closeOrder();
loading = null;
1 year ago
}
1 year ago
}
}