|
Thanks a lot for this quite useless answer. After 25 years developing software, about half of that threaded server applications in C++, I do have a slight idea of accomplishing this task, but I do not have sufficient knowledge of C# yet to do it.
So if you can not contribute anything useful to the forum, don't contribute at all.
|
|
|
|
|
Andreas Saurwein Franci Gonçalves wrote: So if you can not contribute anything useful to the forum, don't contribute at all.
Some people find my charming sarcasm useful. You can't please all the people all the time. So I will contribute what and when I want and not check in with your opinion. Thanks for the suggestion though. Have a nice day.
led mike
|
|
|
|
|
Andreas Saurwein Franci Gonçalves wrote: After 25 years developing software, about half of that threaded server applications in C++, I do have a slight idea of accomplishing this task, but I do not have sufficient knowledge of C# yet to do it.
Whatever. I am closing in on 20 years, with a big segment in the middle doing multi-threaded C++ server development. Someone with that background should not be struggling with such a basic issue just because the language/platform has changed.
led mike
|
|
|
|
|
Well, so as you are obviously an expert, you most surely can give an simple example in a few lines of code how to circumvent the situation. (And even if you are not an C# expert it should not be hard to answer just because its not your language of experience).
|
|
|
|
|
Andreas Saurwein Franci Gonçalves wrote: how to circumvent the situation.
Possibly, if you had described the situation accurately. As it is I can't make any sense of what you posted.
foreach(something in somethingelse) that loop is bogus, foreach(type instance <span style="color: Blue;">in</span> collection) , as is your definition of something versus how you claim to use it.
Andreas Saurwein Franci Gonçalves wrote: the something is actually a dictionary<string,><string,>
If something is a Dictionary<string, whatever> then there is no something.Key nor something.Value
add_a_job_to_the_threadpool(delegate { myFunction(something.Key, something.Value); } ); I have no idea what your requirements are nor what the existing code structure is since you obviously did not post it. Makes it rather difficult to offer any lines of code that could be helpful.
Since you appear to be struggling with how to pass the state information to each thread context. Making the following major assumptions I would say:
foreach(string skey in somethingDictionary.Keys)
add( delegate{ myFunction( skey, somethingDictionary); } ); myFunction can then obtain it's state information, or whatever it is, from the dictionary using the key
led mike
|
|
|
|
|
Thanks for confirming that you have not the slightest idea about threading and C#. You might also wish to lookup the Dictionary enumerator again on MSDN.
|
|
|
|
|
Andreas Saurwein Franci Gonçalves wrote: Thanks for confirming that you have not the slightest idea about threading and C#
Anytime. And no I have not use the new dynamic typing features in C#. After years of experiencing the benefits of strongly typed environments over untyped like javascript, I have no plans to.
I see Nick fixed your inaccurate code posting for you. That information would have been very helpful to my understanding your post.
Nick Butler wrote:
foreach( var something in somethingelse )
{
led mike
|
|
|
|
|
No he didn't fix it, just came up with something. And if you really want to see "CODE" :
foreach(KeyValuePair<string, myClass> kvp in somethingelse)
add( delegate { someFunc(kvp.Key, kvp.Value.memberXY); } );
|
|
|
|
|
Now that looks like something that would compile. So each time someFunc is executed it receives the same myClass reference? Did you solve the problem yet? It sounds like you did.
led mike
|
|
|
|
|
Both parameters are equal in all functions that did not execute yet, so if the thread pool is stopped and only started after adding all jobs, all jobs will refer to the last element in the dictionary, both key and value.
The iterator copy "seems" to solve it, I am not through with testing it yet. At a first glance it seems to work.
btw: nice that you could get down to some programmers talk finally
|
|
|
|
|
Sorry for the delayed reply. I was on vacation friday-monday.
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) , 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
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
|
|
|
|
|
As I mentioned, iterator copying does the trick already. Thanks anyway for sharing your thoughts on the topic.
Restructuring so that the class would perform the job doesn't make much sense here as it would shift the whole orientation around and also give responsibility to something that shouldn't have it.
|
|
|
|
|
What an arrogant comment. A complete waste of time and space. Would you like to get that kind of response if you have a question? No, I didn't think so.
Keep It Simple Stupid! (KISS)
|
|
|
|
|
Ben Fair wrote: Would you like to get that kind of response if you have a question?
Yes. Can you give it to me now? Plezzzz, it's urgent.
led mike
|
|
|
|
|
Is this a closures problem?
Have you tried:
foreach( var something in somethingelse )
{
var local = something;
add_a_job_to_the_threadpool(delegate { myFunction(local.Key, local.Value); } );
}
Nick
----------------------------------
Be excellent to each other
|
|
|
|
|
It seems to be. And interestingly your solution actually works. Its (in my case) a lot cheaper to copy the iterator than the value class itself. Should have been logically.
|
|
|
|
|
I want to crearte a web analytic application for my server using C#
does someone knows how to do it?
where can I find some examples?
do you know what are the advantages/disadvantages to creating it
using Java Script
thanks for your help
|
|
|
|
|
Maverickcool wrote: I want to crearte a web analytic application for my server using C#
does someone knows how to do it?
I'm not sure, but I know how to start, Requirements.
Maverickcool wrote: where can I find some examples?
You mean besides on the internet?
Maverickcool wrote: do you know what are the advantages/disadvantages to creating it
using Java Script
Clearly a C# question.
You might consider changing schools since you seem to be learning frighteningly little given you are in school. Or perhaps you are through the classes?
led mike
|
|
|
|
|
hi all
i have a little question for you all. I have a series of panels that are created dynamically in my main form (this is a windows exe) and they all have different attributes that can be assigned to them (unknown amount of attributes, they're assigned dynamically and manually) and what I was wondering was what would be the best way to display them. I was thinking of using a GridView. Basically what I want to do is have a list of attributes and associated values that are also editable. Is a gridview the best way forward or should I be thinking of something else?
All thoughts appreciated, thanks
tim
|
|
|
|
|
You can use the PropertyGrid component, which is basically a grid with Property-Value pairs.
It can be initialized like this:
propertyGrid1.SelectedObject = some_object;
Regards,
Lev
|
|
|
|
|
I need to be able to import data from 2 different Access tables into similar data tables in another Access database. I want to perform this operation in the quickest manner possible. The DataTable.Merge method followed by an updated command is one possibility.
I would prefer, though, to import the data through a SQL statement without using much code. Is there a SQL statement in MS Access that will accomplish this task. Thanks.
|
|
|
|
|
I'm trying to create a website with youtube APIs using C# 2008 (.NET), Being a beginner and getting my feet wet with this, I wonder if anyone can give me some tips n tricks, or possibly an example code/ step by step instructions on doing this.
I've read the 'Developers Guide: .NET' on the code.google.com site and it's like trying to learn french through the internet Confused if you know what I mean. I have made sites before but exclusively with html and css.
Main Questions:
1.What exactly do I write the C# language in? (Im using C# 2008 however how exactly do I put this on my webpage???)
2.I would loove to see a FULL snippet(s) on an actual page with youtube APIs (or any APIs for that matter, since I have not found anything with FULL code start to finish) that I can copy and paste into whatever it is I put the C# language in and try to view it on my webpage and modify it from there.
3. The Developers guide gives this:
The following code retrieves a YouTubeEntry corresponding to a video on YouTube
String videoEntryUrl = "http://gdata.youtube.com/feeds/api/videos/ADos_xW4_J0";
YouTubeEntry videoEntry = (YouTubeEntry) service.Get(videoEntryUrl);
Console.WriteLine("Title: " + videoEntry.Title.Text);
Console.WriteLine(videoEntry.Media.Description.Value);
I would like to know WHERE DO I PUT THIS CODE??
I am a person that learns very well visually, so pictures/code snippets/ illustrations are better than words, unless they're instructions of course. I guess you can understand the urgency of knowing this for me, thanks alot for all help Big Grin
I'm sure one developer can help another developer
Thanks
-Alex-
modified on Thursday, December 11, 2008 12:12 PM
|
|
|
|
|
bmx4637 wrote: I am a person that learns very well visually, so pictures/illustrations are better than words
Try this picture[^]
Oh yeah - use the correct forum next time.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
yeah thanks
|
|
|
|
|
Did I make you cry?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|