From wpf-dev-pack
Explains WPF Dispatcher priority system, threading patterns, and best practices for background operations, UI responsiveness, and task scheduling order.
How this skill is triggered — by the user, by Claude, or both
Slash command
/wpf-dev-pack:threading-wpf-dispatchersonnetThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
| Priority | Value | Use Case |
| Priority | Value | Use Case |
|---|---|---|
| Send | 10 | Synchronous (avoid - deadlock risk) |
| Normal | 9 | Standard operations |
| DataBind | 8 | Binding updates |
| Render | 7 | Rendering operations |
| Loaded | 6 | Loaded event handlers |
| Input | 5 | User input processing |
| Background | 4 | Background tasks (UI stays responsive) |
| ContextIdle | 3 | After context operations |
| ApplicationIdle | 2 | App idle (cache cleanup) |
| SystemIdle | 1 | System idle |
| Inactive | 0 | Disabled |
await Dispatcher.InvokeAsync(() =>
{
// This runs between input processing
ProcessNextChunk();
}, DispatcherPriority.Background);
await Dispatcher.InvokeAsync(() =>
{
// Runs after layout/render
ScrollIntoView(lastItem);
}, DispatcherPriority.Loaded);
Dispatcher.InvokeAsync(() =>
{
// Low priority cleanup
ClearUnusedCache();
}, DispatcherPriority.ApplicationIdle);
Keep UI responsive during long operations:
public async Task ProcessLargeDataAsync(IList<Item> items)
{
for (int i = 0; i < items.Count; i++)
{
Process(items[i]);
// Yield every 100 items to process pending input
if (i % 100 == 0)
{
await Dispatcher.Yield(DispatcherPriority.Background);
UpdateProgress(i, items.Count);
}
}
}
// Check if on UI thread
if (!Dispatcher.CheckAccess())
{
Dispatcher.Invoke(() => UpdateUI());
return;
}
// From background thread
await Task.Run(() =>
{
var result = HeavyComputation();
// Marshal back to UI
Dispatcher.Invoke(() => DisplayResult(result));
});
// ❌ Send priority - can cause deadlock
Dispatcher.Invoke(() => {}, DispatcherPriority.Send);
// ❌ Blocking UI thread
Thread.Sleep(1000);
// ✅ Use async/await instead
await Task.Delay(1000);
npx claudepluginhub christian289/dotnet-with-claudecode --plugin wpf-dev-packCreates WPF animations using Storyboard, Timeline, and EasingFunction patterns for UI transitions, state change visualizations, and interactive feedback effects.
Correctly handle async/await patterns, thread switching, and JoinableTaskFactory usage in Visual Studio extensions, covering VisualStudio.Extensibility, VSIX Community Toolkit, and legacy VSSDK approaches.
Guides C# async/await patterns including Task, ValueTask, async streams, and cancellation for responsive applications. Use when writing asynchronous C# code.