<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.dotnetzone.gr:443/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>.NET Framework</title><link>https://www.dotnetzone.gr:443/cs/forums/14/ShowForum.aspx</link><description>Θέματα για threading, remoting, reflection, exception handling, security, regex κλπ.</description><dc:language>el</dc:language><generator>CommunityServer 2.1 SP3 (Build: 20423.1)</generator><item><title>Απ: Μια διευκρίνηση για το using statement</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/35066.aspx</link><pubDate>Mon, 17 Sep 2007 19:23:05 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:35066</guid><dc:creator>DeClen</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/35066.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=14&amp;PostID=35066</wfw:commentRss><description>Πράγματι &lt;b&gt;dt008&lt;/b&gt; έχεις δίκιο.&lt;br&gt;&lt;br&gt;Σε ευχαριστώ για την απάντηση. &lt;img src="http://www.dotnetzone.gr/cs/emoticons/emotion-1.gif" alt="Smile" /&gt;&lt;br&gt;&lt;br&gt;</description></item><item><title>Απ: Μια διευκρίνηση για το using statement</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/35065.aspx</link><pubDate>Mon, 17 Sep 2007 19:10:11 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:35065</guid><dc:creator>Δημήτρης Γκανάτσιος</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/35065.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=14&amp;PostID=35065</wfw:commentRss><description>&lt;P&gt;Εφ'όσον είναι μέσα σε using, εκτελείται πρώτα το dispose και μετά επιστρέφει τιμή η συνάρτηση. Δες εδώ και το παραγόμενο IL&lt;/P&gt;
&lt;P&gt;
&lt;TABLE style="BORDER-RIGHT:#e5e5e5 1px solid;BORDER-TOP:#e5e5e5 1px solid;BORDER-LEFT:#e5e5e5 1px solid;BORDER-BOTTOM:#e5e5e5 1px solid;BACKGROUND-COLOR:#f2f2f2;" cellSpacing=0 cellPadding=0 width="100%" border=0&gt;

&lt;TR style="VERTICAL-ALIGN:top;LINE-HEIGHT:normal;"&gt;
&lt;TD style="WIDTH:40px;TEXT-ALIGN:right;"&gt;&lt;PRE style="BORDER-RIGHT:#e7e7e7 1px solid;PADDING-RIGHT:2px;PADDING-LEFT:2px;FONT-SIZE:11px;PADDING-BOTTOM:2px;MARGIN:0px;COLOR:gray;PADDING-TOP:2px;FONT-FAMILY:courier new;"&gt;1&lt;BR&gt;2&lt;BR&gt;3&lt;BR&gt;4&lt;BR&gt;5&lt;BR&gt;6&lt;BR&gt;7&lt;BR&gt;8&lt;BR&gt;9&lt;BR&gt;10&lt;BR&gt;11&lt;BR&gt;12&lt;BR&gt;13&lt;BR&gt;14&lt;BR&gt;15&lt;BR&gt;16&lt;BR&gt;17&lt;BR&gt;18&lt;BR&gt;19&lt;BR&gt;20&lt;BR&gt;21&lt;BR&gt;22&lt;BR&gt;23&lt;BR&gt;24&lt;BR&gt;25&lt;BR&gt;26&lt;BR&gt;27&lt;BR&gt;28&lt;BR&gt;29&lt;BR&gt;30&lt;BR&gt;31&lt;BR&gt;32&lt;BR&gt;33&lt;BR&gt;34&lt;BR&gt;35&lt;BR&gt;36&lt;BR&gt;37&lt;BR&gt; &lt;/PRE&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;PRE style="PADDING-RIGHT:2px;PADDING-LEFT:8px;PADDING-BOTTOM:2px;MARGIN:0px;PADDING-TOP:2px;"&gt;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:black;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:green;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;.method&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;public&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;hidebysig&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;static&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;int32&lt;/SPAN&gt;  DoIt() &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;cil&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;managed&lt;/SPAN&gt;&lt;BR&gt;{&lt;BR&gt;  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:green;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;// Code size       33 (0x21)&lt;/SPAN&gt;&lt;BR&gt;  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:green;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;.maxstack&lt;/SPAN&gt;  2&lt;BR&gt;  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:green;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;.locals&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;init&lt;/SPAN&gt; ([0] &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;class&lt;/SPAN&gt; [System.Data]System.Data.SqlClient.SqlConnection myCon,&lt;BR&gt;           [1] &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;int32&lt;/SPAN&gt; x,&lt;BR&gt;           [2] &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;int32&lt;/SPAN&gt; CS$1$0000,&lt;BR&gt;           [3] &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;bool&lt;/SPAN&gt; CS$4$0001)&lt;BR&gt;  IL_0000:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;nop&lt;/SPAN&gt;&lt;BR&gt;  IL_0001:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;newobj&lt;/SPAN&gt;     &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;instance&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;void&lt;/SPAN&gt; [System.Data]System.Data.SqlClient.SqlConnection::&lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:green;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;.ctor&lt;/SPAN&gt;()&lt;BR&gt;  IL_0006:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;stloc.0&lt;/SPAN&gt;&lt;BR&gt;  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:green;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;.try&lt;/SPAN&gt;&lt;BR&gt;  {&lt;BR&gt;    IL_0007:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;nop&lt;/SPAN&gt;&lt;BR&gt;    IL_0008:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;ldc.i4.0&lt;/SPAN&gt;&lt;BR&gt;    IL_0009:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;stloc.1&lt;/SPAN&gt;&lt;BR&gt;    IL_000a:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;ldloc.1&lt;/SPAN&gt;&lt;BR&gt;    IL_000b:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;stloc.2&lt;/SPAN&gt;&lt;BR&gt;    IL_000c:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;leave.s&lt;/SPAN&gt;    IL_001e&lt;BR&gt;  }  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:green;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;// end .try&lt;/SPAN&gt;&lt;BR&gt;  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;finally&lt;/SPAN&gt;&lt;BR&gt;  {&lt;BR&gt;    IL_000e:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;ldloc.0&lt;/SPAN&gt;&lt;BR&gt;    IL_000f:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;ldnull&lt;/SPAN&gt;&lt;BR&gt;    IL_0010:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;ceq&lt;/SPAN&gt;&lt;BR&gt;    IL_0012:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;stloc.3&lt;/SPAN&gt;&lt;BR&gt;    IL_0013:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;ldloc.3&lt;/SPAN&gt;&lt;BR&gt;    IL_0014:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;brtrue.s&lt;/SPAN&gt;   IL_001d&lt;BR&gt;    IL_0016:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;ldloc.0&lt;/SPAN&gt;&lt;BR&gt;    IL_0017:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;callvirt&lt;/SPAN&gt;   &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;instance&lt;/SPAN&gt; &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;void&lt;/SPAN&gt; [mscorlib]System.IDisposable::Dispose()&lt;BR&gt;    IL_001c:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;nop&lt;/SPAN&gt;&lt;BR&gt;    IL_001d:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;endfinally&lt;/SPAN&gt;&lt;BR&gt;  }  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:green;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;// end handler&lt;/SPAN&gt;&lt;BR&gt;  IL_001e:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;nop&lt;/SPAN&gt;&lt;BR&gt;  IL_001f:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;ldloc.2&lt;/SPAN&gt;&lt;BR&gt;  IL_0020:  &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:blue;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;ret&lt;/SPAN&gt;&lt;BR&gt;} &lt;SPAN style="FONT-WEIGHT:normal;FONT-SIZE:11px;COLOR:green;FONT-FAMILY:Courier New;BACKGROUND-COLOR:transparent;"&gt;// end of method Program::DoIt&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ο compiler βάζει όλο το using σε ένα try-catch-finally block, κάνει dispose στο finally, και κάνει return μετά το finally.&lt;/P&gt;</description></item><item><title>Μια διευκρίνηση για το using statement</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/35064.aspx</link><pubDate>Mon, 17 Sep 2007 19:05:16 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:35064</guid><dc:creator>DeClen</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/35064.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=14&amp;PostID=35064</wfw:commentRss><description>Παιδιά καλημέρα,&lt;br&gt;&lt;br&gt;Θέλω μια διευκρίνηση για τη χρήση του &lt;b&gt;using statement&lt;/b&gt;. Ρίξτε μια ματιά στα παρακάτω κομματάκι κώδικα...&lt;br&gt;&lt;br&gt;&lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt;&lt;tr style="vertical-align:top;line-height:normal;"&gt;&lt;td style="width:40px;text-align:right;"&gt;&lt;pre style="margin:0px;padding:2px;font-family:courier new;font-size:11px;color:gray;"&gt;1&lt;br&gt;2&lt;br&gt;3&lt;br&gt;4&lt;br&gt;5&lt;br&gt;6&lt;br&gt;7&lt;br&gt;8&lt;br&gt;9&lt;br&gt;10&lt;br&gt;11&lt;br&gt;12&lt;br&gt;13&lt;br&gt;14&lt;br&gt;15&lt;br&gt; &lt;/pre&gt;&lt;/td&gt;&lt;td&gt;&lt;pre style="margin:0px;padding:2px 2px 2px 8px;"&gt;&lt;span style="color:Black;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;&lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;static&lt;/span&gt; int DoIt()&lt;br&gt;{&lt;br&gt;      &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;using&lt;/span&gt; (SqlConnection myCon &lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;new&lt;/span&gt; SqlConnection(...))&lt;br&gt;      {&lt;br&gt;            &lt;br&gt;           int x &lt;span style="color:Red;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;=&lt;/span&gt; 0;&lt;br&gt;&lt;br&gt;          &lt;span style="color:Green;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;// do something and return x&lt;/span&gt;&lt;br&gt;          &lt;span style="color:Green;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;//...&lt;/span&gt;&lt;br&gt;&lt;br&gt;          &lt;span style="color:Blue;background-color:transparent;font-family:Courier New;font-size:11px;font-weight:normal;"&gt;return&lt;/span&gt; x;&lt;br&gt;&lt;br&gt;      }&lt;br&gt;&lt;br&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br&gt;Στον παραπάνω κώδικα ελευθερώνονται τα unmanaged resources? Θέλω να πω ότι αφού εκτελεστεί το &lt;b&gt;return &lt;/b&gt;γίνεται dispose το sql connection ή η εκτέλεση δεν φτάνει το "κλείσιμο" του using;&lt;br&gt;</description></item></channel></rss>