Preventing ThreadAbortException.

  • Thread starter Thread starter Ken Varn
  • Start date Start date
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
-----------------------------------
 
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
 
What about 1.1 framework?

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

EmailID = varnk
Domain = Diebold.com
 
Back
Top