eb24, I haven't tried chrissie1's solution, but I believe he is on the right track. I do have a question for you though. You mentioned that you're using an MVC pattern with WinForms. Is there a framework you're using or is it something you've come up with on your own?
I like your thoughts there JurkMonkey, unfortunately it's not quite what I'm looking for. If the action I needed to perform between the try and the finally was the same every time, it would work. You did give me some thoughts for something else though so I gave you a star. :-)
If anything...
Alex, your response cracked me up. :-) I know very well how to use a try..finally. I really don't know if what I'm after is possible. Here's the jist. In winForms I have methods that have a try..finally in them where the finally is always the same thing. I'm just looking for a way to make...
Instead of this:
public void MyMethod() {
try {
dostuff;
} finally {
do finally stuff;
}
}
I want to do this:
[TryFinally]
public void MyMethod() {
dostuff;
}
I'd like to create an attribute that I can use to wrap a method in a try..finally. I don't know if this is possible, but any ideas would be appreciated. Basically I'd like to be able to do the following:
[TryFinally]
public void MyMethod() {
dostuff;
}
And the code of the method would...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.