开发者

How well the progress report function in classes

开发者 https://www.devze.com 2023-03-08 07:34 出处:网络
I have small in C# project which has several classes. The First copies the files, the second synchronizes database SQL CE from SQL SERVER,

I have small in C# project which has several classes.

The First copies the files, the second synchronizes database SQL CE from SQL SERVER, and the third is packed to ZIP files etc.

I want to almost every function in these classes repoted to what she did, or failed to do something or not.

At this moment i am so in place when something happened to report it calls public event EventHandler OperationStatusChanged, in the StatusEventArgs i pass on the string with a description.

Handling event is in a class that is executing an instance of the class.

Ultimately, I want that all messages, error, etc are stored in the database using Nlog.

It is possible to do it more elegantly than calling event and its handling

Thank you for your time.

开发者_Python百科

Tom


There is nothing wrong in event handling and it is appropriate for asynchronous operations.

However, it looks like your different operations are sequential so your calling class could call them one after the other. To avoid blocking your user interface, start the calling class loop in a separated thread and inform the UX at the end of each operation.

0

精彩评论

暂无评论...
验证码 换一张
取 消