Progress bar and an TFTP library
Hi everyone, in my old .Net 4.7 Framework app I have a frame to performe a firmware upgrade thanks to a tftp library.
The issue is about UI: until now I never succed to show the progress on my form because when I tried I I have always run into infamous Cross-thread operation not valid error.
The library (https://github.com/Callisto82/tftp.net) that I use has a progress method that work very well in console.
What do you think is the best solution to solve this? Something like BackgroundWorker/Thread for the TFTP library calls or something else?
Thanks in advance for your help and sorry for this silly question.
GitHub
GitHub - Callisto82/tftp.net: Implements the TFTP (Trivial File Tra...
Implements the TFTP (Trivial File Transfer) protocol (client/server) in an easy-to-use C#/.NET library. - GitHub - Callisto82/tftp.net: Implements the TFTP (Trivial File Transfer) protocol (client...
6 Replies
You want
Progress<T>
/ IProgress<T>
I suspect. That handles the cross-thread dispatch for you
Wow, thanks a lot for your suggestion. I'll try it asap ^^
(The normal pattern is that the thing that takes a while would accept an
IProgress<T>
... But if it just exposes an event that's easy enough to work around)I noticed you mentioned backgroundworker @matcfs, that shouldn't be used these days
Task.Run vs BackgroundWorker: Intro
This is an introductory post for a new series that I’ll be doing comparing BackgroundWorker to Task.Run (in an async style). I always recommend Task.Run, and I have already written a long post describing why, but I still see some developers resisting the New Way of Doing Things (TM). So this will be a short series where I’ll compare the code sid...
Ouch, I didn't know that, I'm such a newbie 🤦🏻♂️. This is a very useful thing to know, thx