I’ve spent the last couple of days trying to come up with a solution for this, and I can’t seem to find one. I’m trying to do something very simple.
I need to convert my app’s data structure from the previous version’s format to the new one. I want to present the user with a window that shows this upgrade process.
Behind the scenes, I need to loop through every file inside the data folder and re-write the text and modify the folder structure of the files. I can do all of that just fine. But I want to present the user with a simple progress bar. These databases can be quite large, and while the conversion only takes about 10-15 seconds, having the program lockup and beachball is not a good user experience, especially when dealing with their data.
I’ve tried running the code in a thread and using the UpdateUI method inside the thread, but this ends up completely crashing the thread, and the program freezes.
I’ve tried doing the initial folder loop outside of a thread, and only running the thread on each folder. This way I can set the progress bar from outside the thread. But then I get a ThreadAccessingUI exception, even though I never do any UI work inside the thread and I wait until the thread is completed before calling it again with the next folderitem.
How can I get this to work? It seems like such an unbelievably simple concept, but I’ve been coming up empty and feel like I must be missing something.
Thanks for any advice you guys can provide!