|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Preventing ThreadAbortException.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" <nospam> wrote in message You need a Constrained Execution Region.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. 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 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 Show quoteHide quote "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 > > What about 1.1 framework?
-- Show quoteHide quote----------------------------------- 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 > > "Ken Varn" <nospam> wrote in message The only option I know of is the BeginCriticalRegion stuff.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? http://msdn2.microsoft.com/en-us/library/system.threading.thread.begincriticalregion.aspx
Other interesting topics
CultureInfo.NumericFormat and System.Convert
Unhandled Exception in Windows Service Launching and Monitoring Executables aspnet user Where is the parameter argument collection? Using IPC question: one process as IPC client and server at same time problem. .NET 2.0 Enterprise Library 2.0 installation problem communicate between two exe applications Testing for invalid characters when creating a directory? |
|||||||||||||||||||||||