/// <summary> /// Sets the cursor property of the framework element to the "Wait" cursor and /// automatically resets the cursor to the default cursor when the dispatcher becomes idle again. /// </summary> /// <param name="frameworkElement">The element on which to set the cursor.</param> /// <param name="priority">The dispatcher priority used for waiting.</param> public static void StartLocal(FrameworkElement frameworkElement, DispatcherPriority priority) { if (frameworkElement.Cursor == Cursors.Wait) { return; } frameworkElement.Cursor = Cursors.Wait; // Wait until the WM_CURSOR message has been processed and the cursor is visible: frameworkElement.ProcessMessages(); frameworkElement.BeginInvoke(priority, () => frameworkElement.Cursor = null); }