Click here to Skip to main content
15,893,790 members
Home / Discussions / C#
   

C#

 
AnswerRe: Thread Performance Pin
Nicholas Butler18-Sep-09 0:12
sitebuilderNicholas Butler18-Sep-09 0:12 
AnswerRe: Thread Performance Pin
Luc Pattyn18-Sep-09 2:08
sitebuilderLuc Pattyn18-Sep-09 2:08 
QuestionWeb Browser Event Hook - Problems Pin
Jacobb Michael17-Sep-09 23:31
Jacobb Michael17-Sep-09 23:31 
AnswerRe: Web Browser Event Hook - Problems Pin
omizyurko6-Jun-11 2:21
omizyurko6-Jun-11 2:21 
AnswerRe: Web Browser Event Hook - Problems Pin
j to the 4n8-Nov-13 0:05
j to the 4n8-Nov-13 0:05 
QuestionHelp making threads work in C# similar to Java Pin
Cruces17-Sep-09 23:17
Cruces17-Sep-09 23:17 
AnswerRe: Help making threads work in C# similar to Java Pin
Nicholas Butler18-Sep-09 0:19
sitebuilderNicholas Butler18-Sep-09 0:19 
GeneralRe: Help making threads work in C# similar to Java Pin
Cruces18-Sep-09 2:14
Cruces18-Sep-09 2:14 
Thank you for the reply I tried coding all options mentioned in the article but it does not seem to work for me.

I've tried many solutions using the following code to test them:

private void button1_Click(object sender, EventArgs e)
        {
            Thread t1 = new Thread(DoWork);
            Thread t2 = new Thread(DoWork);
            Thread t3 = new Thread(DoWork);
            Thread t4 = new Thread(DoWork);
            t1.Start("1");
            t2.Start("2");
            t3.Start("3");
            t4.Start("4");

        }

        public static void DoWork(object a)
        {
            while (true)
            {
                lock (key) {
                    while (block)
                    {
                        Monitor.Wait(key);
                        block = true;
                    
                    } 
                }
                Trace.Write(a.ToString() + "|");
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            for (int i = 1; i < 2000; i++)
            {
            Trace.WriteLine("-");
            lock (key)
            {
                block = false;
                Monitor.PulseAll(key);
            }
            }
        }


(this is the implementation from the document that was linked)

what it shows is something along the lines of :
1234-
-
-
12-
123-
1234-


what I want it to show is this:
1234-
1234-
1234-
1234-
1234-

meaning that when the notify is sent ( the - in the printout) all threads wake up
did I just understand the article wrong?
GeneralRe: Help making threads work in C# similar to Java Pin
Nicholas Butler18-Sep-09 4:17
sitebuilderNicholas Butler18-Sep-09 4:17 
GeneralRe: Help making threads work in C# similar to Java Pin
Cruces18-Sep-09 4:33
Cruces18-Sep-09 4:33 
QuestionHow can we set formats of excel sheet Pin
Gunjan pandey17-Sep-09 23:16
Gunjan pandey17-Sep-09 23:16 
QuestionDraw Controls in Layers Pin
softwarejaeger17-Sep-09 22:52
softwarejaeger17-Sep-09 22:52 
QuestionDatagridview refreshes automatically reflecting changes in database? Pin
LordZoster17-Sep-09 21:54
LordZoster17-Sep-09 21:54 
AnswerRe: Datagridview refreshes automatically reflecting changes in database? Pin
Christian Graus17-Sep-09 21:56
protectorChristian Graus17-Sep-09 21:56 
AnswerRe: Datagridview refreshes automatically reflecting changes in database? Pin
Tamer Oz17-Sep-09 22:05
Tamer Oz17-Sep-09 22:05 
GeneralRe: Datagridview refreshes automatically reflecting changes in database? Pin
Christian Graus17-Sep-09 22:07
protectorChristian Graus17-Sep-09 22:07 
GeneralRe: Datagridview refreshes automatically reflecting changes in database? Pin
Tamer Oz17-Sep-09 22:15
Tamer Oz17-Sep-09 22:15 
GeneralRe: Datagridview refreshes automatically reflecting changes in database? Pin
LordZoster17-Sep-09 22:17
LordZoster17-Sep-09 22:17 
GeneralRe: Datagridview refreshes automatically reflecting changes in database? Pin
Tamer Oz17-Sep-09 22:22
Tamer Oz17-Sep-09 22:22 
GeneralRe: Datagridview refreshes automatically reflecting changes in database? Pin
Christian Graus17-Sep-09 22:23
protectorChristian Graus17-Sep-09 22:23 
GeneralRe: Datagridview refreshes automatically reflecting changes in database? Pin
LordZoster17-Sep-09 22:44
LordZoster17-Sep-09 22:44 
GeneralRe: Datagridview refreshes automatically reflecting changes in database? Pin
Christian Graus17-Sep-09 23:59
protectorChristian Graus17-Sep-09 23:59 
GeneralRe: Datagridview refreshes automatically reflecting changes in database? Pin
Henry Minute18-Sep-09 3:01
Henry Minute18-Sep-09 3:01 
QuestionHow to obtain the switches' mac addres by SNMP Pin
scoket17-Sep-09 20:58
scoket17-Sep-09 20:58 
Questionhow to pass excel application object to automation object? Pin
SRKSHOME17-Sep-09 20:53
SRKSHOME17-Sep-09 20:53 

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.