开发者

C# OnPropertyChangedEvents Implementation and Delegate Question

I have a progress bar on a UI I would like to update when a record gets inserted into my database. I have done this before when I only had a UI Tier and a Busi开发者_运维问答ness Tier with no problems. But I am now breaking my code into a UI Tier, Business Tier, and Data Tier and I can't figure how to properly call my OnPropertyChangedEvent in my Data Tier from my business tier and get my UI to update. I am just starting to get familiar with delegates so any advice would be helpful.

Thanks!


Typicaly you don't want the Data tier to have any knowledge of the business tier, i.e you want the dependencies flowing down (using abstractions) UI --> BLL --> DAL. If you want to get notifications from the data tier when a record is inserted, you could expose events such as OnBeforeInsert, OnAfterInsert,OnBeforeUpdate,OnAfterUpdate etc. in the data tier that the business tier subscribes to. Invoke the event before and after the DB operations, you could create a custom EventArgs class with whatever data you need to get to, which you can then instantiate and pass along when you invoke the event. The UI/BLL can then use this to show progress or do whatever it deems fit.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜