Preventing ThreadAbortException.

K

Ken Varn

Is there any method that I can guarantee execution of a code path within a
thread without a Thread.Abort call interrupting it? I am concerned that a
file write that is done using two calls will not complete if the thread is
aborted before the second call gets a chance to complete.

I thought about setting the priority to highest for the critical calls, but
I was not sure if this would be sufficient or not.

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
-----------------------------------
 
C

Carl Daniel [VC++ MVP]

Ken Varn said:
Is there any method that I can guarantee execution of a code path within a
thread without a Thread.Abort call interrupting it? I am concerned that a
file write that is done using two calls will not complete if the thread is
aborted before the second call gets a chance to complete.

I thought about setting the priority to highest for the critical calls,
but
I was not sure if this would be sufficient or not.

You need a Constrained Execution Region.

http://msdn2.microsoft.com/en-us/library/ms228973(d=ide).aspx

There's a lot of subtlety and a lot of restrictions on using them, but
they're intended to provide a solution to exactly the kind of problem you're
describing.

-cd
 
K

Ken Varn

What about 1.1 framework?

--
-----------------------------------
Ken Varn
Senior Software Engineer
Diebold Inc.

EmailID = varnk
Domain = Diebold.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top