Re: Code FOr CroSS THreAD
So what you're saying is that you're not interested in learning how to do it and understanding it, but rather you just want someone to write the code for you, correct? If that's the case then I'm afraid I can't help you but, if you are interested in learning, I definitely can. Follow the CodeBank link in my signature and check out my Accessing Controls From Worker Threads post. It provides a clear explanation and step by step instructions. If you follow those instructions step by step then it will work. If you don't complete the first step before moving on then you can expect it to likely fail, so don't. Each step is simple so there's no reason that you can't at least perform the first step and post your results here. If you can do that then I'm more than willing to help you go further, but if you just expect it happen of its own accord then you'll be sadly disappointed.
To provide an analogy that might give you a better understanding of what you're doing and why, think of a thread as a person on a production line. Each person can only do one job at a time, so if you have one person working then you are limited to the amount of work that that person can perform. If you have that person working on task A then they can't simultaneously work on task B.
If you hire another person then you can get twice as much work done. You might have one person working repeatedly on task A while the other works repeatedly on task B or you might have both working alternately on task A and task B.
Now, let's imagine that those two people are working on either side of a window. They can see each other but they can't touch. There's a particular tool that needs to be used to complete a task but there's only one of them. Let's say that it is on the first person's side of the window. That person can pick up the tool and use it to perform the task. The other person can't though. They reach out for the tool and they bump into the window. They just checked whether they could use the tool or not and found that they couldn't. As such, they can't complete the task. They then call over someone else and ask them to go around to the other side of the window and ask the other person to use the tool to complete the task. That person walks around to a door and crosses to the other side of the window and asks the person who does have access to the tool to complete the task. The second person delegated a task to the first person because they had access to the tool. Does that sound similar to any other situation? Like maybe a secondary thread delegating a task to the UI thread because it has access to the controls on the form?
Re: Code FOr CroSS THreAD
That is one convoluted metaphor. I prefer my flaming highway of death metaphor :P
Re: Code FOr CroSS THreAD
thank you jmcilhinney..is not that i dont want to learn i doo...i like your example..is just that i needed examples like 1 apple + 2 apples= 3 apples...sort of ,for kids..cuz this part multi threding i dont understand much ..im still learning...and thiis site and ppl like you have help me a lot, obviously showing me through the right direction, ill read the link you suggested
thank you all for your replys..
Re: Code FOr CroSS THreAD
Multi-threading is not fruit. It is complicated. My CodeBank submission breaks it down about as simply as is possible. If you follow the steps I provided then it will work every time.
Re: Code FOr CroSS THreAD
Quote:
Originally Posted by
Emcrank
You need to use delegates, i suggest you search google.
This is a prime example of the kettle calling the pot black.
Re: Code FOr CroSS THreAD
Quote:
Originally Posted by
jmcilhinney
Multi-threading is not fruit.
Quote of the day :D