代码拉取完成,页面将自动刷新
同步操作将从 勒密尔朗/studentPhotoCollection 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
using System;
using System.Threading;
namespace StudentPhotoCollection
{
class LoadingHelper
{
#region 相关变量定义
/// <summary>
/// 定义委托进行窗口关闭
/// </summary>
private delegate void CloseDelegate();
private static LoadingForm loadingForm;
private static readonly Object syncLock = new Object(); //加锁使用
#endregion
/// <summary>
/// 显示loading框,使用者调用
/// </summary>
public static void ShowLoadingForm()
{
// Make sure it is only launched once.
if (loadingForm != null)
return;
Thread thread;
try
{
thread = new Thread(new ThreadStart(LoadingHelper.ShowForm))
{
IsBackground = true
};
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
}
catch (Exception)
{
thread = null;
}
}
/// <summary>
/// 关闭loading框,使用者调用
/// </summary>
public static void CloseLoadingForm()
{
Thread.Sleep(50); //可能到这里线程还未起来,所以进行延时,可以确保线程起来,彻底关闭窗口
if (loadingForm != null)
{
lock (syncLock)
{
Thread.Sleep(50);
if (loadingForm != null)
{
Thread.Sleep(50); //通过三次延时,确保可以彻底关闭窗口
loadingForm.Invoke(new CloseDelegate(LoadingHelper.CloseForm));
}
}
}
}
/// <summary>
/// 显示窗口
/// </summary>
private static void ShowForm()
{
LoadingHelper.CloseForm();
loadingForm = new LoadingForm();
loadingForm.ShowDialog();
}
/// <summary>
/// 关闭窗口
/// </summary>
private static void CloseForm()
{
if (loadingForm != null)
{
loadingForm.CloseForm();
loadingForm = null;
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。