Click here to Skip to main content
15,921,660 members
Home / Discussions / C#
   

C#

 
AnswerRe: typeof operator Pin
Christian Graus22-Nov-08 22:34
protectorChristian Graus22-Nov-08 22:34 
GeneralRe: typeof operator Pin
George_George22-Nov-08 22:43
George_George22-Nov-08 22:43 
AnswerRe: typeof operator [modified] Pin
HosamAly22-Nov-08 23:52
HosamAly22-Nov-08 23:52 
GeneralRe: typeof operator Pin
George_George22-Nov-08 23:59
George_George22-Nov-08 23:59 
GeneralRe: typeof operator Pin
Ed.Poore23-Nov-08 1:04
Ed.Poore23-Nov-08 1:04 
QuestionSystem.Double (CLR type) vs double (C# type) Pin
devvvy22-Nov-08 22:02
devvvy22-Nov-08 22:02 
AnswerRe: System.Double (CLR type) vs double (C# type) Pin
Christian Graus22-Nov-08 22:34
protectorChristian Graus22-Nov-08 22:34 
AnswerRe: System.Double (CLR type) vs double (C# type) Pin
Dave Kreskowiak23-Nov-08 5:16
mveDave Kreskowiak23-Nov-08 5:16 
QuestionLINQ to SQL question, what would be the effect if I change the database table structure ??1 Pin
Nadia Monalisa22-Nov-08 20:39
Nadia Monalisa22-Nov-08 20:39 
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 

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.