I found something very curious today:
I have a standard c# Windows Form type program that has a couple of threads in it.
One thread is the "Stop" thread. In it, when the work of the thread is complete I want to re-enable some form controls.
Originally, Stop was run in the main thread but for other reasons, I had to put into a separate thread. So the code was unchanged from the beginning. Then I realized that there was another control I had to enable.
I added 'tsbPlay.Enabled=true' and as expected I got a cross threading error when I got there.
Then I noticed that just above I noticed that I was calling 'this.buttonx.enabled' all along with no problems. So I change 'tsbPlay.Enabled=true' to 'this.tsbPlay.Enabled=true' and all worked error free.
Having successfully blown my mind I decided to ask the experts .
I'm sure that this method is probably not cool but why does it not work?
Thanks
Moose
P.S. I'm using VS2005.
Rajesh SinghRank #1,806 · 824 reputationPosted Dec 17, 2015, 12:25 AM EST
Mickey MarshallRank #1,520 · 1K reputationPosted Dec 17, 2015, 4:40 AM EST
Thank you for your reply but you missed the point:
It actually works without a cross thread error when I use 'this.control'.
Moose
Rajesh SinghRank #1,806 · 824 reputationPosted Dec 17, 2015, 9:22 PM EST
Mickey MarshallRank #1,520 · 1K reputationPosted Dec 18, 2015, 3:06 AM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts