简体   繁体   中英

Does Catel have any way of displaying windows(based on ViewModel) synchronously?

I'm trying to update a large project to latest stable Catel version and need to find a ShowDialog alternative, converting to ShowDialogAsync is simply impossible in our use case.

The project stopped integrating Catel updates with Catel V4.2 and there is a large code base with ~960 synchronous (Main Thread) calls to a method using bool? IUIVisualizerService.ShowDialog(IViewModel) most of which process the returned bool? from ShowDialog and perform conditional handling.
So I need to find an alternative that waits for the window to close without blocking the UIThread and it's currently unfeasible to alter all the calling methods to async, use TaskCommands or move the handling of results to EventHandlers due to lack of manpower and company internal management.

This is the old V4.2 code:

var uiVisualizerService = this.GetDependencyResolver().Resolve<IUIVisualizerService>();
return uiVisualizerService.ShowDialog(viewModelToShow);

The ideal scenario is that there is still a Catel service which works like ShowDialog or alternatively find a different way to show DataWindows synchronously.

Edit:
In case it isn't obvious I can't simply use await due to methods in 500+ classes needing to be rewritten and than manually tested(company policy) or use Task.Wait, Task.Result... etc. due to WPF limitation (if I use blocking call on main thread UI freezes up due to intricacies of the WPF causing it to wait for a chance to runSync on the main thread in order to do the actual displaying of the new window(all UI components actually) which causes an inescapable deadlock), so it definitely can't be solved in any of the conventional ways.

There are more changes in Catel since 4.2 than just the async stuff that would worry me if I were you. Not sure why you haven't kept it all up-to-date, but you have 2 options:

  1. Stick with 4.2 (would only recommend if product is in maintenance mode)
  2. Bite the bullet and update, you will love the new features and performance upgrades

4.2 was released on September 1, 2015, and 5.9 on January 28, 2019. That's almost 4 years of development and a breaking change release that you need to plan.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM