Click here to Skip to main content
15,921,959 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to show data in DataGrid on PPC Pin
Alomgir Miah15-Sep-05 17:45
Alomgir Miah15-Sep-05 17:45 
QuestionString Search on a Treeview Pin
jhrbek15-Sep-05 16:06
jhrbek15-Sep-05 16:06 
AnswerRe: String Search on a Treeview Pin
jhrbek15-Sep-05 17:00
jhrbek15-Sep-05 17:00 
GeneralRe: String Search on a Treeview Pin
Alomgir Miah15-Sep-05 17:56
Alomgir Miah15-Sep-05 17:56 
Questioncode complies blows sky high on button OK click Pin
Anonymous15-Sep-05 15:51
Anonymous15-Sep-05 15:51 
AnswerRe: code complies blows sky high on button OK click Pin
Christian Graus15-Sep-05 15:54
protectorChristian Graus15-Sep-05 15:54 
GeneralRe: code complies blows sky high on button OK click Pin
Anonymous15-Sep-05 16:34
Anonymous15-Sep-05 16:34 
GeneralRe: code complies blows sky high on button OK click Pin
Christian Graus15-Sep-05 16:55
protectorChristian Graus15-Sep-05 16:55 
GeneralRe: code complies blows sky high on button OK click Pin
Anonymous15-Sep-05 18:18
Anonymous15-Sep-05 18:18 
GeneralRe: code complies blows sky high on button OK click Pin
Christian Graus18-Sep-05 10:57
protectorChristian Graus18-Sep-05 10:57 
AnswerRe: code complies blows sky high on button OK click Pin
Guffa15-Sep-05 19:18
Guffa15-Sep-05 19:18 
Questioncan't get variable into Watch Window? Pin
Anonymous15-Sep-05 14:18
Anonymous15-Sep-05 14:18 
AnswerRe: can't get variable into Watch Window? Pin
Christian Graus15-Sep-05 14:20
protectorChristian Graus15-Sep-05 14:20 
QuestionProblem with database Pin
kavicky15-Sep-05 13:49
kavicky15-Sep-05 13:49 
AnswerRe: Problem with database Pin
Christian Graus15-Sep-05 14:23
protectorChristian Graus15-Sep-05 14:23 
QuestionEvent handlers in multi-threaded apps Pin
brucemo15-Sep-05 13:32
brucemo15-Sep-05 13:32 
AnswerRe: Event handlers in multi-threaded apps Pin
brucemo15-Sep-05 13:57
brucemo15-Sep-05 13:57 
GeneralRe: Event handlers in multi-threaded apps Pin
brucemo15-Sep-05 14:35
brucemo15-Sep-05 14:35 
AnswerRe: Event handlers in multi-threaded apps Pin
Judah Gabriel Himango15-Sep-05 15:27
sponsorJudah Gabriel Himango15-Sep-05 15:27 
AnswerRe: Event handlers in multi-threaded apps Pin
leppie15-Sep-05 16:12
leppie15-Sep-05 16:12 
GeneralRe: Event handlers in multi-threaded apps Pin
brucemo15-Sep-05 17:07
brucemo15-Sep-05 17:07 
I'll describe it a little differently.

I have a black box. Code subscribes to the black box by adding event handlers to the delegates that are the visible interface of the black box.

Maybe the black box uses threads, and maybe it doesn't. It's a regular class now but eventually it will be an interface class, and some of the derived classes I have in mind will not use threads. In any case, the subscribers ideally should not have to care. They should just sit back and wait, and when their event handlers fire, they should fire in the same thread that they are sitting in, because doing otherwise is about as polite as dumping coffee in their lap.

The generic event invoker you provide would work. It's pretty much what I do now, but the problem is that ISynchronizeInvoke object. As far as I know I can't make one of those on the fly. I have to pass one in, probably as an argument to the constructor of the black box. And unless I am misunderstanding C# reality, which is certainly likely since I have been doing C# for about a week now, the one I pass in won't necessarily apply to all of the events attached to the delegate.

I think that I have two choices:

1) Do it as you suggest, which results in a "control" or "form" parameter being passed in to my black box, and which results in my being able to accept customers from one thread only.

2) Make sure that all of the black box customers are aware that I'm going to stab them in the eye by calling into their event handler code from a different thread. This is weird and unpleasant code, but it would work, and the black box itself is clean.

I think I would lean toward the first solution, because the oddball code is in the black box, where it where it should be.

I wish there was another solution -- that it was possible to call a delegate in such a way that all of the event handler calls magically found their way back to the correct thread.

Thank you again,

bruce

GeneralRe: Event handlers in multi-threaded apps Pin
Andy Brummer15-Sep-05 17:38
sitebuilderAndy Brummer15-Sep-05 17:38 
GeneralRe: Event handlers in multi-threaded apps Pin
brucemo15-Sep-05 21:29
brucemo15-Sep-05 21:29 
QuestionA Specific Control Query Pin
udaan15-Sep-05 12:41
udaan15-Sep-05 12:41 
AnswerRe: A Specific Control Query Pin
Guffa15-Sep-05 13:46
Guffa15-Sep-05 13:46 

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.