Click here to Skip to main content
15,915,810 members
Home / Discussions / C#
   

C#

 
GeneralRe: ByteArray To Image Pin
AB77719-Jan-07 0:39
AB77719-Jan-07 0:39 
QuestionFormatting DateTime Pin
GermanDM8-Jan-07 22:47
GermanDM8-Jan-07 22:47 
AnswerRe: Formatting DateTime Pin
Christian Graus8-Jan-07 23:18
protectorChristian Graus8-Jan-07 23:18 
AnswerRe: Formatting DateTime Pin
Tyler458-Jan-07 23:18
Tyler458-Jan-07 23:18 
AnswerRe: Formatting DateTime Pin
Fedor Hajdu9-Jan-07 0:14
professionalFedor Hajdu9-Jan-07 0:14 
GeneralRe: Formatting DateTime Pin
J4amieC8-Jan-07 23:48
J4amieC8-Jan-07 23:48 
QuestionSQL-DMO. How to use JobFilter in EnumJobs method Pin
Member 6972548-Jan-07 22:05
Member 6972548-Jan-07 22:05 
QuestionManipulating controls in C#2005 Pin
Mr.Sam8-Jan-07 21:50
Mr.Sam8-Jan-07 21:50 
AnswerRe: Manipulating controls in C#2005 Pin
Stefan Troschuetz8-Jan-07 22:25
Stefan Troschuetz8-Jan-07 22:25 
GeneralRe: Manipulating controls in C#2005 Pin
Mr.Sam8-Jan-07 23:42
Mr.Sam8-Jan-07 23:42 
GeneralRe: Manipulating controls in C#2005 Pin
Stefan Troschuetz9-Jan-07 0:13
Stefan Troschuetz9-Jan-07 0:13 
AnswerRe: Manipulating controls in C#2005 Pin
V.8-Jan-07 22:32
professionalV.8-Jan-07 22:32 
AnswerRe: Manipulating controls in C#2005 Pin
Christian Graus8-Jan-07 23:31
protectorChristian Graus8-Jan-07 23:31 
AnswerRe: Manipulating controls in C#2005 Pin
Bekjong9-Jan-07 1:40
Bekjong9-Jan-07 1:40 
GeneralRe: Manipulating controls in C#2005 Pin
Mr.Sam9-Jan-07 2:13
Mr.Sam9-Jan-07 2:13 
GeneralRe: Manipulating controls in C#2005 Pin
Bekjong9-Jan-07 2:23
Bekjong9-Jan-07 2:23 
GeneralRe: Manipulating controls in C#2005 Pin
Mr.Sam9-Jan-07 2:49
Mr.Sam9-Jan-07 2:49 
GeneralRe: Manipulating controls in C#2005 Pin
Bekjong9-Jan-07 2:59
Bekjong9-Jan-07 2:59 
AnswerRe: Manipulating controls in C#2005 Pin
Luc Pattyn9-Jan-07 2:12
sitebuilderLuc Pattyn9-Jan-07 2:12 
GeneralRe: Manipulating controls in C#2005 Pin
Mr.Sam9-Jan-07 2:19
Mr.Sam9-Jan-07 2:19 
GeneralRe: Manipulating controls in C#2005 Pin
Luc Pattyn9-Jan-07 2:38
sitebuilderLuc Pattyn9-Jan-07 2:38 
Hi,

assume a text editor with most operations running on main (= UI) thread, but with search capabilities running on a background thread. When search thread has found what it was
looking for, it calls UpdateSelection() methode to update several things in the user
interface.

Since UpdateSelection is not called from UI thread and needs to access some
controls, we make it such that it calls itself again, this time on UI thread:

public delegate void UpdateSelectionDelegate(int start, int length);
private TextBox textBox;
private MenuItem menuCopy;
private MenuItem menuCut;
 
public void UpdateSelection(int start, int length) {
	if (InvokeRequired) {
		// this method calls itself, in order for it run on UI thread
		Invoke(new UpdateSelectionDelegate(UpdateSelection),
			new object[]{start, length});
	} else {
		// adjust here whatever control needs updated on the user interface
		textBox.Select(start, length);
		menuCopy.Enabled=length!=0;
		menuCut.Enabled=length!=0;
	}
}


In the example three controls get updated by implementing and executing only one Invoke.

Smile | :)






Luc Pattyn

GeneralRe: Manipulating controls in C#2005 Pin
Mr.Sam9-Jan-07 2:51
Mr.Sam9-Jan-07 2:51 
GeneralRe: Manipulating controls in C#2005 Pin
Luc Pattyn9-Jan-07 4:05
sitebuilderLuc Pattyn9-Jan-07 4:05 
QuestionContextSwitchDeadlock Pin
Nooie8-Jan-07 21:46
Nooie8-Jan-07 21:46 
AnswerRe: ContextSwitchDeadlock Pin
Stefan Troschuetz8-Jan-07 22:29
Stefan Troschuetz8-Jan-07 22:29 

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.