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

C#

 
QuestionActive Directory and C# Pin
Imtiaz Murtaza24-May-08 12:59
Imtiaz Murtaza24-May-08 12:59 
AnswerRe: Active Directory and C# Pin
teejayem24-May-08 13:39
teejayem24-May-08 13:39 
AnswerRe: Active Directory and C# Pin
Anthony Mushrow24-May-08 14:14
professionalAnthony Mushrow24-May-08 14:14 
AnswerRe: Active Directory and C# Pin
mav.northwind25-May-08 21:26
mav.northwind25-May-08 21:26 
QuestionPattern for GUI invocations from worker threads Pin
Jörgen Sigvardsson24-May-08 12:23
Jörgen Sigvardsson24-May-08 12:23 
AnswerRe: Pattern for GUI invocations from worker threads Pin
Jörgen Sigvardsson24-May-08 13:46
Jörgen Sigvardsson24-May-08 13:46 
GeneralRe: Pattern for GUI invocations from worker threads Pin
Dario Solera25-May-08 0:02
Dario Solera25-May-08 0:02 
GeneralRe: Pattern for GUI invocations from worker threads Pin
Jörgen Sigvardsson25-May-08 0:30
Jörgen Sigvardsson25-May-08 0:30 
Suppose I have an event handler:
void OnWhatever(...) {
   textBox.Text = "Very bad thing from a different thread context";
}
I rewrote it like this:
void Invoke(Delegate del) {
   Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Input, del);
}
 
void OnWhatever(...) {
   Invoke(new Action( () => { textBox.Text = "This is safe from a different thread context"; } ));
}
This'll make sure that the textbox's text property is only set on the GUI thread. If you're used to COM, it's like calling an STA object's method - it gets synchronized by the message pump.

I've tried to make this more generic, so that when you register the event handler (which you know will be called from a different thread), you register a chaining delegate handler which will automatically chain the event call through the dispatcher. I haven't had any success yet, as the last step in the invocation list always gives me an invalid parameter count exception. I have no idea why, and the debugger doesn't give me much else. Frown | :(

Of course, I'm working with WPF. If you're working with Windows Forms, I think you'll have to take a look at Control.Invoke() or something like that, to dispatch the calls to the GUI thread.

--
Kein Mitleid Für Die Mehrheit

GeneralRe: Pattern for GUI invocations from worker threads Pin
Dario Solera25-May-08 0:33
Dario Solera25-May-08 0:33 
Questionwindows service - not allowing shut down Pin
tai-fun24-May-08 12:06
tai-fun24-May-08 12:06 
AnswerRe: windows service - not allowing shut down Pin
Dario Solera25-May-08 0:38
Dario Solera25-May-08 0:38 
QuestionIs it possible to place my C# form beneath the desktop icons? Pin
buypymoncdnx24-May-08 10:51
buypymoncdnx24-May-08 10:51 
AnswerRe: Is it possible to place my C# form beneath the desktop icons? Pin
Ed.Poore24-May-08 12:01
Ed.Poore24-May-08 12:01 
QuestionProblem in Reports Pin
Shuaib wasif khan24-May-08 10:26
Shuaib wasif khan24-May-08 10:26 
QuestionHow recognize the keyboard pressed button ? ( code attached ) Pin
Yanshof24-May-08 8:11
Yanshof24-May-08 8:11 
QuestionHow to AutoScrolling my richTextBox ? Pin
hdv21224-May-08 7:36
hdv21224-May-08 7:36 
AnswerRe: How to AutoScrolling my richTextBox ? Pin
Giorgi Dalakishvili24-May-08 8:35
mentorGiorgi Dalakishvili24-May-08 8:35 
QuestionPlease tell me how to view structure of .mdb file? [modified] Pin
cuongmits24-May-08 7:15
cuongmits24-May-08 7:15 
QuestionHow to launch your application minimized in sidebar not in taskbar by pressing a certain key Pin
Sakshi Smriti24-May-08 6:52
Sakshi Smriti24-May-08 6:52 
AnswerRe: How to launch your application minimized in sidebar not in taskbar by pressing a certain key Pin
Ed.Poore24-May-08 9:21
Ed.Poore24-May-08 9:21 
AnswerRe: How to launch your application minimized in sidebar not in taskbar by pressing a certain key Pin
DaveyM6924-May-08 10:05
professionalDaveyM6924-May-08 10:05 
QuestionApplying Jena in .NET framework Pin
Asemeh24-May-08 5:38
Asemeh24-May-08 5:38 
QuestionEditable ComboBox in DataGridView Pin
Abdul Rahman Hamidy24-May-08 2:53
Abdul Rahman Hamidy24-May-08 2:53 
QuestionGet SHA-1 Hash of a File without opening it? Pin
Ian Uy24-May-08 2:20
Ian Uy24-May-08 2:20 
AnswerRe: Get SHA-1 Hash of a File without opening it? Pin
Ravi Bhavnani24-May-08 3:01
professionalRavi Bhavnani24-May-08 3:01 

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.