We have a WPF dialog library, which exposes an async Task ShowAsync(...)
method, library has to be used. Around it, we've built a MVVM-based singleton service, DialogService
with our own async ShowAsync
method, and view models call it when needed. The problem is, the library does not support showing more than one dialog at the time and we have to keep the dispatcher thread working, so if another operation requests a dialog before the user closes the first one, the library throws an exception, which then cascades into another dialog call, so on and so on.
So we need to implement some sort of queueing, in the sense that second task cannot even begin (be cold?) until the first task is completed. It all has to happen in dispatcher thread, but on a plus not the ShowAsync is always called from the dispatcher thread and we use ConfigureAwait(true)
on calling library method.
Some of the calls to dialog service have their own ContinueWith
constructs, if that is important.
I've seen some solutions like SerialQueue et al, but they all deal with serializing tasks in general, without caring on what context and thread they run, we need a more WPFy solution where everything runs on dispatcher thread without making it unresponsive.
Any ideas would be welcome.