|
already saw it, that's what i did
thanks any way
|
|
|
|
|
No, that's not what you did. Read more carefully.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
i meant to "that's what i did eventually..."
|
|
|
|
|
You just have to set the name of the method that should run in you thread.
Something like this:
Thread t1 = new Thread(new ThreadStart(mt.fillCaps));
To work with parameter you have to use the ParameterizedThreadStart delegate.
Thread t1 = new Thread(new ParameterizedThreadStart(mt.fillCaps));
Thread t2 = new Thread(new ParameterizedThreadStart(mt.fillUnCaps));
t1.Start(englishCapLetter);
t2.Start(englishSmallLetter);
t1.Join();
t2.Join();
Greetings
Covean
|
|
|
|
|
that's exactly what i did...
and it did work with complex object (Dictionary\instance of class etc...) but when i tried that method with "cooler" object as string, i got null after the thread has stopped running, i tried to debug, and i see that inside the thread the string object does get data from file, but it doesn't give it back to the one who called that thread. i was thinking that ParameterizedThreadStart transfers by ref, was i wrong ?
thanks
p.s
of course, i would like to get some ideas how to solve that issue...
|
|
|
|
|
you don't need the ref keyword, all objects are passed by reference, i.e. their pointer value is shared, so every party involved can modify the object (mind you: modify, not replace).
|
|
|
|
|
then why i cant transfer string object by ref ? it's only transfers by val
|
|
|
|
|
strings (and almost all structs) are immutable, when you think you modify a string, you are actually replacing it by a new string. Most objects are not immutable, so you can pass Forms and Controls and Dictonaries around, modify them, and have the caller see your modifications without limitations.
|
|
|
|
|
Damn, I need to type faster
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Mark Nischalke wrote: I need to type faster
yes.
or start sooner.
|
|
|
|
|
Too simple. I'll just issue a DoS attack on your servers to prevent you from posting
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
That won't work either, CodeProject just tried that, and all they got was more messages. See my sig.
|
|
|
|
|
As Luc pointed out objects passed by ref are able to be modified. This is because you are working with the memory location of the actual object. Since a string is immutable any time it is modified an new one is created which points to a new memory location, not the original that may have been passed to the method.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
i see...
then i need to wrap this string with other object list for exmp, and to pass list to the thread, after creating new string, return it with the "ref" list, am i right ?
|
|
|
|
|
If you mean to create some object that contains the string and passing it around, then yes, I believe that will work for you. Although more levels of abstraction does not improve anything. Possibly you could re-engineer the code so it is not necessary?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
it did work for me...
and yes, i can re-engineer the code, but it means that i will work in single thread mode... i wanted to practice on multithreading...
|
|
|
|
|
Re-engineering doesn't necessarily mean you have to give up on multithreading, just use it differently
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I have 2 forms.
both are loaded.
i wanat with click in Datagrid cell string display in Text box in Other FORM
hoW can i do?
|
|
|
|
|
Raise an event in the form that has the DataGrid in it, and subscribe to the event in the other form.
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
If I had received a penny everytime this question was asked here...
|
|
|
|
|
It should be in the FAQs !
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
|
Simulation domain name server resolution
Its riches action.
Request : Middle exchange item of newss client and server according to just protocol DNS
Server can resort to help of domain name lysis by command gethostbyname và gethostbyaddr
dragon_cntt@yahoo.com
send mail !!!
|
|
|
|
|
Never post your email address to any forum, unless you really like spam!
If anyone here want to contact you, you will receive an email (just like this one) when they reply to you, or they can send you an email without exposing your email address via the "email" button at the bottom of each message.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
I doubt you're going to get an answer for this question. I can't understand what it is you're talking about nor what the error is norwhat your code is supposed to be doing, nor what you want it to do, nor how this relates to C#...
|
|
|
|