c# - Delete directory of files, UI is not updating -
I am trying to delete a directory of files, and I am removing each file, I want to update the UI which is currently being removed.
I have a code in my ViewModel:
Private Zero ExecuteDeleteCommand () {var files = new DirectoryInfo (BackupDirectory) .GetFiles (); Forward (files in file) {ActivityFileName = fileName; File.Delete (); }} XAM (nothing special, just a TextBlock ): & lt; TextBlock Text = "{Binding ActivityFileName}" /> What is happening is that files are deleted in that directory, but updating to the Older file in the UI is running. ActivityFileName call OnPropertyChanged , so I know that is not a problem. I have created a directory that contains approximately 23k files, so I know that I should look something other than the last file when it is complete.
I just think why he is not updating the UI in every call.
The problem is that you are using the UI thread to perform your work. As a result, the UI will not be updated until it is executed. DeleteCommand () Returns.
If you want to update the UI, then you need to work on the background thread. Keep in mind that the OnPropertyChanged () call will need to be sent back to the UI thread.
Comments
Post a Comment