Click here to Skip to main content
15,912,897 members
Home / Discussions / C#
   

C#

 
GeneralRe: Draw line in RichTextBox C# Pin
Luc Pattyn6-Sep-10 6:06
sitebuilderLuc Pattyn6-Sep-10 6:06 
GeneralRe: Draw line in RichTextBox C# Pin
OriginalGriff6-Sep-10 5:56
mveOriginalGriff6-Sep-10 5:56 
QuestionRe: Draw line in RichTextBox C# Pin
jojoba20116-Sep-10 6:28
jojoba20116-Sep-10 6:28 
AnswerRe: Draw line in RichTextBox C# Pin
Luc Pattyn6-Sep-10 6:53
sitebuilderLuc Pattyn6-Sep-10 6:53 
GeneralRe: Draw line in RichTextBox C# Pin
DaveyM696-Sep-10 8:07
professionalDaveyM696-Sep-10 8:07 
AnswerRe: Draw line in RichTextBox C# Pin
Luc Pattyn6-Sep-10 8:19
sitebuilderLuc Pattyn6-Sep-10 8:19 
GeneralRe: Draw line in RichTextBox C# Pin
DaveyM696-Sep-10 8:27
professionalDaveyM696-Sep-10 8:27 
QuestionMulti-threading and function recursion with a form [modified] Pin
fdsfsa76f7sa66-Sep-10 3:11
fdsfsa76f7sa66-Sep-10 3:11 
I haven't done multi-threading before, so I need a bit of help with this.
I have a form with a button. When user clicks on the button for the first time, a recursive function is called. When a certain condition in the function is true, I want the function to wait where it's at for the next button click.

An example:
void ButtonClick(object sender, EventArgs e)
{
if (running)
{
//Monitor.Pulse(this) - notify the function to continue
}
else functionCall(0);
}

void functionCall(int num)
{
if (num % 2 == 0)
{
displaySomething();
//Monitor.Wait(???) - wait for a button click
}
functionCall(num + 1);
}


How would I do this? If I understand correctly, I have to create a class for the thread that's going to run the recursive function. The second thread should wait for the main thread (Monitor.Wait(MainThread???)) to give a pulse, but how would I define the main thread?

modified on Monday, September 6, 2010 2:37 PM

AnswerRe: Mulit-threading and function recursion with a form Pin
Pete O'Hanlon6-Sep-10 3:23
mvePete O'Hanlon6-Sep-10 3:23 
GeneralRe: Mulit-threading and function recursion with a form Pin
fdsfsa76f7sa66-Sep-10 4:17
fdsfsa76f7sa66-Sep-10 4:17 
GeneralRe: Mulit-threading and function recursion with a form Pin
Kubajzz6-Sep-10 4:31
Kubajzz6-Sep-10 4:31 
GeneralRe: Mulit-threading and function recursion with a form Pin
fdsfsa76f7sa66-Sep-10 5:13
fdsfsa76f7sa66-Sep-10 5:13 
GeneralRe: Mulit-threading and function recursion with a form Pin
Pete O'Hanlon6-Sep-10 4:59
mvePete O'Hanlon6-Sep-10 4:59 
AnswerRe: Mulit-threading and function recursion with a form Pin
Cracked-Down6-Sep-10 8:21
Cracked-Down6-Sep-10 8:21 
AnswerDammit, stop blabbing and give him the code already... Pin
lepipele7-Sep-10 4:53
lepipele7-Sep-10 4:53 
GeneralRe: Dammit, stop blabbing and give him the code already... Pin
lepipele7-Sep-10 5:10
lepipele7-Sep-10 5:10 
GeneralRe: Dammit, stop blabbing and give him the code already... Pin
fdsfsa76f7sa69-Sep-10 1:27
fdsfsa76f7sa69-Sep-10 1:27 
GeneralRe: Dammit, stop blabbing and give him the code already... Pin
lepipele9-Sep-10 6:20
lepipele9-Sep-10 6:20 
QuestionRe: Dammit, stop blabbing and give him the code already... [modified] Pin
fdsfsa76f7sa69-Sep-10 22:37
fdsfsa76f7sa69-Sep-10 22:37 
AnswerRe: Dammit, stop blabbing and give him the code already... Pin
lepipele13-Sep-10 9:30
lepipele13-Sep-10 9:30 
GeneralRe: Dammit, stop blabbing and give him the code already... Pin
fdsfsa76f7sa67-Sep-10 5:24
fdsfsa76f7sa67-Sep-10 5:24 
QuestionWindows Task Scheduler problem Pin
Tridip Bhattacharjee6-Sep-10 1:45
professionalTridip Bhattacharjee6-Sep-10 1:45 
AnswerRe: Windows Task Scheduler problem Pin
Pete O'Hanlon6-Sep-10 2:12
mvePete O'Hanlon6-Sep-10 2:12 
GeneralBSCS FINAL PROJECT Pin
HUSSNAIN TOUFIQ6-Sep-10 0:53
HUSSNAIN TOUFIQ6-Sep-10 0:53 
GeneralRe: BSCS FINAL PROJECT Pin
OriginalGriff6-Sep-10 0:57
mveOriginalGriff6-Sep-10 0:57 

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.