Implementing RAII in C#

前端 未结 4 1550
一整个雨季
一整个雨季 2021-01-18 00:47

I have an InfoPath form which I need to conditionally disable it\'s OnChange events. Since it\'s not possible to bind the event handlers after the form has loaded, I\'m forc

4条回答
  •  轮回少年
    2021-01-18 01:05

    If you can move from C# to C++.NET (still 100% .NET if compiled with clr:safe), then you can use msclr::auto_handle which acts just like a smart pointer such as auto_ptr etc...

    What it really does behind the scene in IL is a bunch of try/fault commands but this is all completely invisible to the developer and user. The whole process is simply better IMO.

提交回复
热议问题