Click here to Skip to main content
15,902,114 members
Home / Discussions / C#
   

C#

 
GeneralRe: Cannot evaluate expression because a native frame is on top of the call stack Pin
josephdalebert7-Nov-13 5:41
josephdalebert7-Nov-13 5:41 
GeneralRe: Cannot evaluate expression because a native frame is on top of the call stack Pin
Alan Balkany7-Nov-13 5:45
Alan Balkany7-Nov-13 5:45 
GeneralRe: Cannot evaluate expression because a native frame is on top of the call stack Pin
josephdalebert7-Nov-13 6:05
josephdalebert7-Nov-13 6:05 
QuestionCustom configuration in app.config Pin
Member 102635196-Nov-13 23:29
Member 102635196-Nov-13 23:29 
AnswerRe: Custom configuration in app.config Pin
Abhinav S7-Nov-13 0:13
Abhinav S7-Nov-13 0:13 
GeneralRe: Custom configuration in app.config Pin
Member 102635197-Nov-13 0:48
Member 102635197-Nov-13 0:48 
AnswerRe: Custom configuration in app.config Pin
Abhinav S7-Nov-13 0:57
Abhinav S7-Nov-13 0:57 
GeneralRe: Custom configuration in app.config Pin
Member 102635197-Nov-13 1:19
Member 102635197-Nov-13 1:19 
GeneralRe: Custom configuration in app.config Pin
Dave Kreskowiak7-Nov-13 1:29
mveDave Kreskowiak7-Nov-13 1:29 
GeneralRe: Custom configuration in app.config Pin
Member 102635197-Nov-13 19:58
Member 102635197-Nov-13 19:58 
AnswerRe: Custom configuration in app.config Pin
Richard MacCutchan7-Nov-13 0:53
mveRichard MacCutchan7-Nov-13 0:53 
QuestionC# code to fetch all attributes of an element Pin
AshwiniSH6-Nov-13 23:09
professionalAshwiniSH6-Nov-13 23:09 
AnswerRe: C# code to fetch all attributes of an element Pin
Pete O'Hanlon6-Nov-13 23:41
mvePete O'Hanlon6-Nov-13 23:41 
AnswerRe: C# code to fetch all attributes of an element Pin
Abhinav S7-Nov-13 0:15
Abhinav S7-Nov-13 0:15 
QuestionHow to perform file transfer using SFTP using Genymed SSH2 dll in dot net Pin
superselector6-Nov-13 23:08
superselector6-Nov-13 23:08 
Questionvolatile Pin
devvvy6-Nov-13 19:35
devvvy6-Nov-13 19:35 
how come adding "volatile" in below code snippet didn't help?

The output, without "volatile" would be like:
m=1,000,000, n=999,993

My expectation was, m=n=1,000,000 exactly if I added "volatile".

<br />
using System;<br />
using System.Collections;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
using System.Threading;<br />
using System.Threading.Tasks;<br />
<br />
namespace SimpleConsole<br />
{<br />
    class Test<br />
    {<br />
        static int i = 0;<br />
        <br />
        static volatile int n = 0;<br />
        static int m = 0;<br />
<br />
        static Object SyncRoot = new Object();<br />
<br />
        static void Main(string[] args)<br />
        {<br />
            Task[] Tasks = new Task[100];<br />
<br />
            try<br />
            {<br />
                n = 0;<br />
                m = 0;<br />
                for (i = 0; i < 100; i++)<br />
                {<br />
                    Task t = new Task(<br />
                        () =><br />
                        {<br />
                            for (int j = 0; j < 1000000; j++)<br />
                            {<br />
                                n++; // no lock<br />
<br />
                                lock (SyncRoot)<br />
                                {<br />
                                    m++;<br />
                                }<br />
                            }<br />
                        }<br />
                    );<br />
<br />
                    Tasks[i] = t;<br />
<br />
                    t.Start();<br />
                }<br />
<br />
                Task.WaitAll(Tasks);<br />
                Console.WriteLine("n=" + n + ", m=" + m);<br />
<br />
                Console.WriteLine("Hit any key to exit");<br />
                Console.ReadLine();<br />
            }<br />
            catch (Exception Ex)<br />
            {<br />
                Console.WriteLine("Error in main: " + Ex.Message);<br />
            }<br />
<br />
            return;<br />
        }<br />
    }<br />
}<br />

dev

AnswerRe: volatile Pin
OriginalGriff7-Nov-13 0:03
mveOriginalGriff7-Nov-13 0:03 
AnswerRe: volatile Pin
Richard Deeming7-Nov-13 2:28
mveRichard Deeming7-Nov-13 2:28 
QuestionReal world experience with SqlDependency? Pin
Ron Beyer6-Nov-13 15:04
professionalRon Beyer6-Nov-13 15:04 
JokeRe: Real world experience with SqlDependency? Pin
_Maxxx_6-Nov-13 20:04
professional_Maxxx_6-Nov-13 20:04 
Questionerror can't access a doublebuffer class derived from panel class due to protected level Pin
Gene Baptiste6-Nov-13 12:32
Gene Baptiste6-Nov-13 12:32 
AnswerRe: error can't access a doublebuffer class derived from panel class due to protected level Pin
Pete O'Hanlon6-Nov-13 12:44
mvePete O'Hanlon6-Nov-13 12:44 
QuestionIndex of Button Pin
cdpsource6-Nov-13 11:37
cdpsource6-Nov-13 11:37 
AnswerRe: Index of Button Pin
BillWoodruff6-Nov-13 12:29
professionalBillWoodruff6-Nov-13 12:29 
Questionsorting a string Pin
vkEE6-Nov-13 8:13
vkEE6-Nov-13 8:13 

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.