Click here to Skip to main content
15,887,361 members
Home / Discussions / C#
   

C#

 
GeneralRe: Passing parameters to anonymous functions in threads Pin
Andreas Saurwein11-Dec-08 9:03
Andreas Saurwein11-Dec-08 9:03 
GeneralRe: Passing parameters to anonymous functions in threads Pin
led mike11-Dec-08 10:35
led mike11-Dec-08 10:35 
GeneralRe: Passing parameters to anonymous functions in threads Pin
Andreas Saurwein11-Dec-08 10:43
Andreas Saurwein11-Dec-08 10:43 
GeneralRe: Passing parameters to anonymous functions in threads Pin
led mike11-Dec-08 11:34
led mike11-Dec-08 11:34 
GeneralRe: Passing parameters to anonymous functions in threads Pin
Andreas Saurwein11-Dec-08 11:42
Andreas Saurwein11-Dec-08 11:42 
GeneralRe: Passing parameters to anonymous functions in threads Pin
led mike11-Dec-08 11:56
led mike11-Dec-08 11:56 
GeneralRe: Passing parameters to anonymous functions in threads Pin
Andreas Saurwein11-Dec-08 12:31
Andreas Saurwein11-Dec-08 12:31 
GeneralRe: Passing parameters to anonymous functions in threads Pin
led mike16-Dec-08 10:19
led mike16-Dec-08 10:19 
Sorry for the delayed reply. I was on vacation friday-monday. Big Grin | :-D
Andreas Saurwein Franci Gonçalves wrote:
Both parameters are equal in all functions that did not execute yet

Yes, that would be correct, unless you define the anonymous method to use the state of the loop.
foreach(KeyValuePair<string, myClass> kvp in somethingelse)
  add( delegate (object oValue){ mytype t = (mytype)oValue; someFunc(t.name, t.memberXY); }, somethingelse[kvp.Key] );
This won't compile of course because I had to fill in unknown stuff . Also made the assumption that the object in the collection has the key as well because, at the risk of sounding arrogant (again) Smile | :) , that's how I would design it given my past experience developing multi-threaded applications.

Also some refactoring might be in order based on what type memberXY is.
foreach( string skey in somethingelse.Keys)
   add( delegate (object obj){ mytype t = (mytype)obj; t.doWork() }, new mytype( somethingelse[skey]));
The mytype ctor might need more parameters depending on it's responsibility during mytype.doWork()

Again depending on what memberXY is that, or the following, might just be shifted to memberXY or something that works with it.

Alternatively, if the doWork() responsibility makes sense for the class you already have ( the one with the .memberXY ), then the method fulfilling that responsibility could be added to it.

Andreas Saurwein Franci Gonçalves wrote:
btw: nice that you could get down to some programmers talk finally Poke tongue | ;-P

That's what I do this for. Texting does not always work for me. I did not interpret the pseudo code in your first post accurately. Seeing the actual code resolved that problem for me.


led mike

GeneralRe: Passing parameters to anonymous functions in threads Pin
Andreas Saurwein16-Dec-08 11:24
Andreas Saurwein16-Dec-08 11:24 
GeneralRe: Passing parameters to anonymous functions in threads Pin
Ben Fair11-Dec-08 8:41
Ben Fair11-Dec-08 8:41 
GeneralRe: Passing parameters to anonymous functions in threads Pin
led mike11-Dec-08 8:44
led mike11-Dec-08 8:44 
AnswerRe: Passing parameters to anonymous functions in threads Pin
Nicholas Butler11-Dec-08 10:48
sitebuilderNicholas Butler11-Dec-08 10:48 
GeneralRe: Passing parameters to anonymous functions in threads Pin
Andreas Saurwein11-Dec-08 10:58
Andreas Saurwein11-Dec-08 10:58 
QuestionWeb analytic application Pin
Maverickcool11-Dec-08 7:08
Maverickcool11-Dec-08 7:08 
AnswerRe: Web analytic application Pin
led mike11-Dec-08 8:03
led mike11-Dec-08 8:03 
QuestionGridView ? Pin
tim_gunning11-Dec-08 6:34
tim_gunning11-Dec-08 6:34 
AnswerRe: GridView ? Pin
Lev Danielyan11-Dec-08 6:43
Lev Danielyan11-Dec-08 6:43 
QuestionImport Data into Access DataTable from another Access Database Pin
polishprogrammer11-Dec-08 5:54
polishprogrammer11-Dec-08 5:54 
QuestionYouTube API with C# Pin
bmx463711-Dec-08 4:40
bmx463711-Dec-08 4:40 
AnswerRe: YouTube API with C# PinPopular
#realJSOP11-Dec-08 4:51
mve#realJSOP11-Dec-08 4:51 
GeneralRe: YouTube API with C# Pin
bmx463711-Dec-08 4:54
bmx463711-Dec-08 4:54 
GeneralRe: YouTube API with C# PinPopular
#realJSOP11-Dec-08 4:55
mve#realJSOP11-Dec-08 4:55 
GeneralRe: YouTube API with C# Pin
Dalek Dave11-Dec-08 5:42
professionalDalek Dave11-Dec-08 5:42 
JokeRe: YouTube API with C# Pin
Paul Conrad11-Dec-08 6:41
professionalPaul Conrad11-Dec-08 6:41 
GeneralRe: YouTube API with C# Pin
carbon_golem11-Dec-08 5:19
carbon_golem11-Dec-08 5:19 

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.