Click here to Skip to main content
15,905,614 members
Home / Discussions / C#
   

C#

 
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 
QuestionRichTextbox to send and receive data Pin
Ralf Hägenläuer15-Sep-05 10:09
Ralf Hägenläuer15-Sep-05 10:09 
QuestionDataSet Select statment Pin
zaboboa15-Sep-05 8:51
zaboboa15-Sep-05 8:51 
AnswerRe: DataSet Select statment Pin
Turtle Hand15-Sep-05 9:21
Turtle Hand15-Sep-05 9:21 
AnswerRe: DataSet Select statment Pin
Carl Mercier15-Sep-05 9:48
Carl Mercier15-Sep-05 9:48 
QuestionActiveReports +C# Pin
Agyeman15-Sep-05 8:33
Agyeman15-Sep-05 8:33 
Questionshort/easy question Pin
Lapje15-Sep-05 8:27
Lapje15-Sep-05 8:27 
AnswerRe: short/easy question Pin
Judah Gabriel Himango15-Sep-05 10:13
sponsorJudah Gabriel Himango15-Sep-05 10:13 
GeneralRe: short/easy question Pin
Lapje15-Sep-05 23:31
Lapje15-Sep-05 23:31 
GeneralRe: short/easy question Pin
Judah Gabriel Himango16-Sep-05 5:16
sponsorJudah Gabriel Himango16-Sep-05 5:16 
QuestionProgrammatically Deleting Data from a File Pin
JMitchem15-Sep-05 7:37
JMitchem15-Sep-05 7:37 
AnswerRe: Programmatically Deleting Data from a File Pin
Judah Gabriel Himango15-Sep-05 10:22
sponsorJudah Gabriel Himango15-Sep-05 10:22 
GeneralRe: Programmatically Deleting Data from a File Pin
JMitchem15-Sep-05 12:10
JMitchem15-Sep-05 12:10 
AnswerRe: Programmatically Deleting Data from a File Pin
Guffa15-Sep-05 11:44
Guffa15-Sep-05 11:44 

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.