Click here to Skip to main content
15,916,463 members
Home / Discussions / C#
   

C#

 
GeneralRe: Report Creating in C# ? Pin
Mohammad Dayyan18-Sep-09 2:15
Mohammad Dayyan18-Sep-09 2:15 
AnswerRe: Report Creating in C# ? Pin
MiddleTommy18-Sep-09 3:39
MiddleTommy18-Sep-09 3:39 
QuestionHow to scroll the scrollbar of treeview control automatically? Pin
kmb8918-Sep-09 0:31
kmb8918-Sep-09 0:31 
AnswerRe: How to scroll the scrollbar of treeview control automatically? Pin
stancrm18-Sep-09 0:41
stancrm18-Sep-09 0:41 
GeneralRe: How to scroll the scrollbar of treeview control automatically? Pin
kmb8918-Sep-09 0:48
kmb8918-Sep-09 0:48 
AnswerRe: How to scroll the scrollbar of treeview control automatically? Pin
Tamer Oz18-Sep-09 0:44
Tamer Oz18-Sep-09 0:44 
QuestionUnable to set program icon Pin
yeah100017-Sep-09 23:57
yeah100017-Sep-09 23:57 
AnswerRe: Unable to set program icon Pin
Christian Graus17-Sep-09 23:58
protectorChristian Graus17-Sep-09 23:58 
GeneralRe: Unable to set program icon [modified] Pin
yeah100018-Sep-09 0:29
yeah100018-Sep-09 0:29 
AnswerRe: Unable to set program icon Pin
PIEBALDconsult18-Sep-09 4:37
mvePIEBALDconsult18-Sep-09 4:37 
GeneralRe: Unable to set program icon Pin
yeah100020-Sep-09 20:15
yeah100020-Sep-09 20:15 
QuestionMultiThreading in c# Pin
nisharafic17-Sep-09 23:51
nisharafic17-Sep-09 23:51 
AnswerRe: MultiThreading in c# Pin
stancrm18-Sep-09 0:01
stancrm18-Sep-09 0:01 
AnswerRe: MultiThreading in c# Pin
Jacobb Michael18-Sep-09 1:01
Jacobb Michael18-Sep-09 1:01 
QuestionThread Performance Pin
Member 368144317-Sep-09 23:47
Member 368144317-Sep-09 23:47 
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 

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.