دوست خوبم ابتدا یه فرم ایجاد کن یه دونه هم لیبل بزار روش و روش بنویس لطفا صبر کنید. و کد های زیر رو بزارید داخلش
private static Thread _LoadingScreenThread;
private static Wait _ls;
private static bool _shown = false;
private static Form _parent;
public static void ShowLoadingScreen(Form parent)
{
_parent = parent;
if (_LoadingScreenThread == null)
{
_LoadingScreenThread = new Thread(new ThreadStart(DoShowLoadingScreen));
_LoadingScreenThread.SetApartmentState(ApartmentSt ate.STA);
_LoadingScreenThread.IsBackground = true;
_LoadingScreenThread.Start();
}
}
public static void CloseLoadingScreen()
{
System.Threading.Thread.Sleep(250);
if (_ls != null && _ls.InvokeRequired)
{
_ls.Invoke(new MethodInvoker(CloseLoadingScreen));
}
else
{
if (_shown)
{
_shown = false;
Application.ExitThread();
}
if (_LoadingScreenThread != null) _LoadingScreenThread.Interrupt();
try
{
_ls.Close();
_ls.Dispose();
}
catch
{}
_LoadingScreenThread = null;
}
}
private static void DoShowLoadingScreen()
{
_ls = new Wait();
//_ls.Wait_Progress.IsRunning = true;
_ls.ShowDialog();
}
private void Wait_Load(object sender, EventArgs e)
{
this.Activate();
}
public static void Thread1Job()
{
for (int counter = 0; counter < 50; counter++)
{
MessageBox.Show("");
}
}
برا استفادش هم برید تو فرم مورد نظر و قبل از دستوری که میخواید اطلاعات رو بخونید کد زیر رو بزارید
Wait.ShowLoadingScreen(this);
و بعد اینکه دستورتون کامل شد این کد رو بزارید
Wait.CloseLoadingScreen();
منبع این کد هم همین سایته که دوستان زحمتشو کشیدن به منم یاد دادن.(لینکش یادم نیست تو تایپیک هام بگردید پیدا میکنید.) منم مدتها استفاده میکنم ازش. دستشونم درد نکنه.