Click here to Skip to main content
15,905,414 members
Home / Discussions / C#
   

C#

 
AnswerRe: LINQ to SQL question, what would be the effect if I change the database table structure ??1 Pin
Mark Churchill23-Nov-08 12:16
Mark Churchill23-Nov-08 12:16 
GeneralRe: LINQ to SQL question, what would be the effect if I change the database table structure ??1 Pin
Nadia Monalisa23-Nov-08 12:32
Nadia Monalisa23-Nov-08 12:32 
Question.NET Connection pooling max/min setting vs Perfmon Pin
devvvy22-Nov-08 20:25
devvvy22-Nov-08 20:25 
AnswerRe: .NET Connection pooling max/min setting vs Perfmon Pin
Dave Kreskowiak23-Nov-08 5:13
mveDave Kreskowiak23-Nov-08 5:13 
GeneralRe: .NET Connection pooling max/min setting vs Perfmon Pin
devvvy23-Nov-08 15:22
devvvy23-Nov-08 15:22 
GeneralRe: .NET Connection pooling max/min setting vs Perfmon Pin
Dave Kreskowiak24-Nov-08 16:36
mveDave Kreskowiak24-Nov-08 16:36 
Questionsignature of _inp and _outp in msvcrt.dll Pin
asugix22-Nov-08 16:25
asugix22-Nov-08 16:25 
QuestionThread.Abort and IL Pin
devvvy22-Nov-08 13:27
devvvy22-Nov-08 13:27 
hello

This article[^] tells me it's possible thread aborted before created file is assigned to variable "w" by looking at IL - I examined IL but not sure how we can arrive at that conclusion:
<br />
Aborting pure .NET code is less problematic, as long as try/finally blocks or using statements are incorporated to ensure proper cleanup takes place should a ThreadAbortException be thrown. However, even then, one can still be vulnerable to nasty surprises. For example, consider the following:<br />
<br />
using (StreamWriter w = File.CreateText ("myfile.txt"))<br />
<br />
  w.Write ("Abort-Safe?");<br />
<br />
C#'s using statement is simply a syntactic shortcut, which in this case expands to the following:<br />
<br />
StreamWriter w;<br />
<br />
w = File.CreateText ("myfile.txt");<br />
<br />
try     { w.Write ("Abort-Safe"); }<br />
<br />
finally { w.Dispose();            }  <br />
<br />
It's possible for an Abort to fire after the StreamWriter is created, but before the try block begins. In fact, by digging into the IL, one can see that it's also possible for it to fire in between the StreamWriter being created and assigned to w:<br />
<br />
IL_0001:  ldstr      "myfile.txt"<br />
<br />
IL_0006:  call       class [mscorlib]System.IO.StreamWriter<br />
<br />
                     [mscorlib]System.IO.File::CreateText(string)<br />
<br />
IL_000b:  stloc.0<br />
<br />
.try<br />
<br />
{<br />
<br />
  ...<br />
<br />
Either way, the Dispose method in the finally block is circumvented, resulting in an abandoned open file handle – preventing any subsequent attempts to create myfile.txt until the application domain ends.<br />


I can't see where in IL the variable "w" get assigned the created file stream writer.

devy

AnswerRe: Thread.Abort and IL Pin
Guffa22-Nov-08 14:16
Guffa22-Nov-08 14:16 
GeneralRe: Thread.Abort and IL Pin
devvvy22-Nov-08 14:34
devvvy22-Nov-08 14:34 
GeneralRe: Thread.Abort and IL Pin
Guffa22-Nov-08 17:01
Guffa22-Nov-08 17:01 
GeneralRe: Thread.Abort and IL Pin
devvvy22-Nov-08 17:03
devvvy22-Nov-08 17:03 
QuestionUSB + C# Pin
E_Gold22-Nov-08 8:34
E_Gold22-Nov-08 8:34 
AnswerRe: USB + C# Pin
Christian Graus22-Nov-08 8:52
protectorChristian Graus22-Nov-08 8:52 
GeneralRe: USB + C# Pin
E_Gold22-Nov-08 9:15
E_Gold22-Nov-08 9:15 
GeneralRe: USB + C# Pin
Christian Graus22-Nov-08 9:56
protectorChristian Graus22-Nov-08 9:56 
GeneralRe: USB + C# PinPopular
Luc Pattyn22-Nov-08 9:27
sitebuilderLuc Pattyn22-Nov-08 9:27 
GeneralRe: USB + C# Pin
Wendelius22-Nov-08 10:56
mentorWendelius22-Nov-08 10:56 
QuestionWM_NCCALCSIZE resizing form continuously Pin
Chris Copeland22-Nov-08 8:09
mveChris Copeland22-Nov-08 8:09 
Questionrichtextbox handle keyup and keydown events Pin
Stephen Po22-Nov-08 6:14
Stephen Po22-Nov-08 6:14 
AnswerRe: richtextbox handle keyup and keydown events Pin
derm222-Nov-08 7:28
derm222-Nov-08 7:28 
Questionc# Window form Data grid view columns show hide problem Pin
veereshIndia22-Nov-08 6:08
veereshIndia22-Nov-08 6:08 
QuestionListview: Make left and right arrow keys jump rows if needed Pin
derm222-Nov-08 4:58
derm222-Nov-08 4:58 
QuestionC# - Raw Socket, Packet filter Pin
Member 468084422-Nov-08 4:02
Member 468084422-Nov-08 4:02 
AnswerRe: C# - Raw Socket, Packet filter Pin
Dave Kreskowiak22-Nov-08 4:29
mveDave Kreskowiak22-Nov-08 4:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.