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
-----------------------------------

Re: Preventing ThreadAbortException. by Carl

Carl
Mon Jul 31 15:36:04 CDT 2006

"Ken Varn" <nospam> wrote in message
news:O5I2X5NtGHA.1504@TK2MSFTNGP03.phx.gbl...
> 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



Re: Preventing ThreadAbortException. by Greg

Greg
Mon Jul 31 15:49:36 CDT 2006

You can look at the safehandle class to see how this is done as well (I
believe it does just this).

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung

"Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@mvps.org.nospam>
wrote in message news:%23xwlyDOtGHA.1224@TK2MSFTNGP03.phx.gbl...
> "Ken Varn" <nospam> wrote in message
> news:O5I2X5NtGHA.1504@TK2MSFTNGP03.phx.gbl...
>> 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
>
>



Re: Preventing ThreadAbortException. by Chris

Chris
Mon Jul 31 17:15:11 CDT 2006

"Ken Varn" <nospam> wrote in message
news:O5I2X5NtGHA.1504@TK2MSFTNGP03.phx.gbl...
> Is there any method that I can guarantee execution of a code path within a
> thread without a Thread.Abort call interrupting it?

The only option I know of is the BeginCriticalRegion stuff.

http://msdn2.microsoft.com/en-us/library/system.threading.thread.begincriticalregion.aspx

--
Chris Mullins
http://www.coversant.net/blogs/cmullins



Re: Preventing ThreadAbortException. by Ken

Ken
Tue Aug 01 15:40:24 CDT 2006

What about 1.1 framework?

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

EmailID = varnk
Domain = Diebold.com
-----------------------------------
"Carl Daniel [VC++ MVP]" <cpdaniel_remove_this_and_nospam@mvps.org.nospam>
wrote in message news:%23xwlyDOtGHA.1224@TK2MSFTNGP03.phx.gbl...
> "Ken Varn" <nospam> wrote in message
> news:O5I2X5NtGHA.1504@TK2MSFTNGP03.phx.gbl...
> > 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
>
>