Created
November 10, 2012 08:27
-
-
Save JakeGinnivan/4050418 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public async void SaveDocument() | |
| { | |
| if (IsWorking) return; | |
| var doc = MDI.ActiveItem as DocumentViewModel; | |
| if (doc != null) | |
| { | |
| using (DoingWork(string.Format("Saving {0}", doc.MarkpadDocument.Title))) | |
| { | |
| await doc.Save(); | |
| await TaskEx.Delay(5000); | |
| } | |
| } | |
| } | |
| //If I add this guy, I get a 5 second UI thread lockup... wtf | |
| public bool CanSaveDocument | |
| { | |
| get { return !IsWorking; } | |
| } |
Author
Stop blaming CM! It's not CM that's blocking if you're using a DelegateCommand because CM isn't involved.
Since the issue also occurs when the property is public and you use a delegate command I'd say it's a weird interaction with WPF bindings, INotifyPropertyChanged and async.
Author
@distantcam I put the delegate command in to fix the issue. DelegateCommand = working, CM = not
Who sets IsWorking, because the moment that is set is when CM will be handling the event not when you hit the await.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I cant see any reason why CM blocks. This is what should happen:
If I use an ICommand, so CanSaveDocument is private, it works great. If I make it public, I get the UI thread lockup. Just dont understand why...