Click here to Skip to main content
16,005,124 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can I delay the painting of a GroupBox control? Pin
JoeRip27-Sep-07 3:12
JoeRip27-Sep-07 3:12 
GeneralRe: How can I delay the painting of a GroupBox control? Pin
TJoe27-Sep-07 3:31
TJoe27-Sep-07 3:31 
GeneralRe: How can I delay the painting of a GroupBox control? Pin
JoeRip27-Sep-07 9:26
JoeRip27-Sep-07 9:26 
GeneralRe: How can I delay the painting of a GroupBox control? Pin
Scott Dorman27-Sep-07 3:51
professionalScott Dorman27-Sep-07 3:51 
GeneralRe: How can I delay the painting of a GroupBox control? Pin
JoeRip27-Sep-07 9:27
JoeRip27-Sep-07 9:27 
GeneralRe: How can I delay the painting of a GroupBox control? Pin
Scott Dorman27-Sep-07 10:20
professionalScott Dorman27-Sep-07 10:20 
QuestionWriting to controls from thread.. Pin
Dio2227-Sep-07 2:40
Dio2227-Sep-07 2:40 
AnswerRe: Writing to controls from thread.. Pin
TJoe27-Sep-07 2:46
TJoe27-Sep-07 2:46 
Here is an example using anonymous delegate:

/// <summary>
/// Gets or sets the <see cref="P:Enabled"/> property and
/// can be called from any thread.
/// </summary>
/// <value><c>true</c> if enabled; otherwise, <c>false</c>.</value>
public Boolean SafeEnabled {
	get {
		if (true == this.InvokeRequired) {
			Boolean enabled = false;
			MethodInvoker method = new MethodInvoker(
				delegate {
					enabled = this.Enabled;
				});
			Invoke(method);
			return enabled;
		}
		else {
			return this.Enabled;
		}
	}
	set {
		if (true == this.InvokeRequired) {
			MethodInvoker method = new MethodInvoker(
				delegate {
					this.Enabled = value;
				});
			Invoke(method);
		}
		else {
			this.Enabled = value;
		}
	}
}


Basically, you need to "Invoke" the method on the thread that created the control. You can use the Invoke method or the BeginInvoke/EndInvoke pair. The latter works like PostMessage in C++, the former works like SendMessage (if you are familiar with those).

Take care,
Tom

-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com

AnswerRe: Writing to controls from thread.. Pin
il_masacratore27-Sep-07 2:51
il_masacratore27-Sep-07 2:51 
AnswerRe: Writing to controls from thread.. Pin
JoeRip27-Sep-07 2:59
JoeRip27-Sep-07 2:59 
AnswerRe: Writing to controls from thread.. Pin
Dio2227-Sep-07 3:19
Dio2227-Sep-07 3:19 
AnswerRe: Writing to controls from thread.. Pin
Ed.Poore27-Sep-07 7:41
Ed.Poore27-Sep-07 7:41 
QuestionWhy does CurrentDirectory change Pin
electriac27-Sep-07 2:15
electriac27-Sep-07 2:15 
AnswerRe: Why does CurrentDirectory change Pin
ATCsharp27-Sep-07 2:18
ATCsharp27-Sep-07 2:18 
GeneralRe: Why does CurrentDirectory change Pin
electriac27-Sep-07 2:45
electriac27-Sep-07 2:45 
AnswerRe: Why does CurrentDirectory change Pin
TJoe27-Sep-07 2:22
TJoe27-Sep-07 2:22 
GeneralRe: Why does CurrentDirectory change Pin
electriac27-Sep-07 2:50
electriac27-Sep-07 2:50 
GeneralRe: Why does CurrentDirectory change Pin
TJoe27-Sep-07 2:53
TJoe27-Sep-07 2:53 
AnswerRe: Why does CurrentDirectory change Pin
Dave Kreskowiak27-Sep-07 4:30
mveDave Kreskowiak27-Sep-07 4:30 
QuestionOnKeyPress and KeyPress Pin
mihksoft27-Sep-07 2:11
mihksoft27-Sep-07 2:11 
AnswerRe: OnKeyPress and KeyPress Pin
TJoe27-Sep-07 2:16
TJoe27-Sep-07 2:16 
AnswerRe: OnKeyPress and KeyPress Pin
Martin#27-Sep-07 2:17
Martin#27-Sep-07 2:17 
QuestionDynamic Class Loading - app.config issue Pin
ATCsharp27-Sep-07 2:04
ATCsharp27-Sep-07 2:04 
AnswerRe: Dynamic Class Loading - app.config issue Pin
TJoe27-Sep-07 2:40
TJoe27-Sep-07 2:40 
GeneralRe: Dynamic Class Loading - app.config issue Pin
TJoe27-Sep-07 2:42
TJoe27-Sep-07 2:42 

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.