Detecting a Dispose() from an exception inside using block

前端 未结 8 594
暖寄归人
暖寄归人 2021-02-01 19:13

I have the following code in my application:

using (var database = new Database()) {
    var poll = // Some database query code.

    foreach (Question question          


        
8条回答
  •  耶瑟儿~
    2021-02-01 19:29

    You could inherit from the Database class and then override the Dispose() method (making sure to close the db resources), this could then raise a custom event to which you can subscribe in your code.

提交回复
热议问题