public static void ShowLoading(bool mouse) { counter++; if (cur != null) { return; } Thread t = new Thread(new ThreadStart(delegate { cur = new Loading(); cur.Location = new Point(Screen.PrimaryScreen.WorkingArea.Right - cur.Width, Screen.PrimaryScreen.WorkingArea.Bottom - cur.Height); cur.Show(); Point l = cur.Location; l.Offset(128, 128); if (mouse) { Cursor.Position = l; } Stopwatch sw = new Stopwatch(); sw.Start(); x = cur.box.Location.X; int last = 0; while (cur.shown) { if (x < 0 || x + 32 > cur.pictureBox1.Width) { dirX = -dirX; } if (y < 0 || y + 32 > cur.pictureBox1.Height) { dirY = -dirY; } x += dirX * speed; y += dirY * speed; cur.box.Location = new Point(x, y); Thread.Sleep(20); //20 ms standard sleep int secs = (int)sw.Elapsed.TotalSeconds; if (cur.label1.Text != operation) { cur.label1.Text = operation; } if (last != secs) { last = secs; cur.label2.Text = secs + "s"; } Application.DoEvents(); } cur.Close(); cur = null; })); t.IsBackground = true; t.Start(); Application.DoEvents(); }