Display a message while executing a method
In my app, I read/parse data that takes some time. While that process is going on I want to display a message on screen indicating the process going on. I beileve I got to use Thread for it, but don't get an idea how to use and implement it.The calling method may throw exception or so.
Any idea/tip on how to achieve the task.开发者_Python百科 Any help is highly appreciated.
Thanks
I'll assume that you're using .Net.
You should use the BackgroundWorker component.
Perform your operation in its DoWork
event (which runs on a background thread), call ReportProgress
to post messages for the UI, and handle ProgressChanged
and RunWorkerCompleted
to update the UI.
精彩评论