Re: overload lock command? maybe others?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



not_a_commie wrote:

Barry Kelly wrote:
using (MyLock.Lock(foo)) ...

Thank you, Barry, very much. That was exactly what I needed to know. I
had not heard of the Monitor class, but that looks to be exactly what
I needed.

I can't see how this would apply to try/catch.

The second approach I listed, the delegate approach, can easily be
applied to try/catch. You pass the code as an anonymous delegate as an
argument.

It's too bad that the
try/catch stuff has to go all the way to the OS level to stop from
executing code.

I typically implement my event handlers inside anonymous delegates
passed to wrappers, as indicated in my grandparent post.

Alternatively, you can add a handler to either:

1) Application.ThreadException - for exceptions thrown during Windows
message processing, typically due to e.g. throwing an exception in a
control's event handler.

2) AppDomain.UnhandledException - for those exceptions that would
otherwise fall off the entire thread's stack.

-- Barry

--
http://barrkel.blogspot.com/
.



Relevant Pages

  • Re: OOP php user system
    ... and TRY/CATCH maybe. ... bool res = f.SetI; ... especially if the exceptions can only be identified by text strings. ... me the 'i' in iTeachersPerStudent isn't the amateurist's mistake of using ...
    (comp.lang.php)
  • Re: new without delete: what will happen
    ... If you're writing try/catch a lot, you're probably not using exceptions ... The idea is to have destructors of local objects perform ...
    (microsoft.public.vc.mfc)
  • Re: [PHP] Try{} Catch()
    ... shouldn't rely on try/catch for algorithm implementation. ... You create exceptions for errors and unexpected behavior. ... and/or sending an error message to the user. ... try/catch works great for small/medium projects, ...
    (php.general)
  • Re: try...catch vs TRY...CATCH
    ... pointers no new'ed exceptions that you then have to delete. ... the environment) implemented in terms of the C++ try/catch mechanisms. ... the macros. ... The only real problem with using try/catch and MFC exceptions is with ...
    (microsoft.public.vc.language)
  • Re: Is there a technique for global error trap?
    ... Although those event handlers are sharing the same stack as other procedures ... exceptions are not normally propagated back through the event dispatcher. ... > the Application object can handle (although I still recommend error ...
    (microsoft.public.vb.general.discussion)