12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System;
- using System.Windows.Forms;
- namespace SmartCoalApplication.Core
- {
- public sealed class WaitCursorChanger : IDisposable
- {
- private Control control;
- private Cursor oldCursor;
- private static int nextID = 0;
- private int id = System.Threading.Interlocked.Increment(ref nextID);
- public WaitCursorChanger(Control control)
- {
- this.control = control;
- this.oldCursor = Cursor.Current;
- Cursor.Current = Cursors.WaitCursor;
- }
- ~WaitCursorChanger()
- {
- Dispose(false);
- }
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
- private void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (this.oldCursor != null)
- {
- Cursor.Current = this.oldCursor;
- this.oldCursor = null;
- }
- }
- }
- }
- }
|