|
-
Oct 1st, 2003, 11:19 AM
#1
Thread Starter
Frenzied Member
Thread Troubles (CF)
Using the Compact Framework.
I'm quite new to .NET and the CF and threading in general. Hope I can get some insight.
I have an app that tries to connect via TCP. Since I want the GUI to be responsive when attempting to connect, I create a thread and start the Connect() method.
My problem is, the Connect() method attempts to change the visibility of ToolBar buttons. If the current Visibility is False and I try to change to True, the Connect() method hangs, also, the GUI is not responsive.
I'm guessing I'm creating a deadlock. Any help is appreciated.
Mike
-
Oct 1st, 2003, 01:03 PM
#2
Lively Member
You cannot mess with controls in a thread. if you do, all bets are off and it will most likely not work. I assume this is what you are doing when you say:
"the Connect() method attempts to change the visibility of ToolBar buttons."
What I would do is have a variable, called InThread lets say
when a user clicks connect, set this to true and start a timer (ie timer is disabled by default and you enable it), along with your thread. In the timers tick event, check the value of InThread. If it is true, toggle visibility. When your thread is done working it can change the value of InThread to false and then when the timer fires again it will see false. Now you code timer.enabled to false and toggle your visibilty again. Something like this would work for the tick event as well:
control.visible = Not InThread
timer.enabled = InThread
that way when the thread is done, you shut off the timer and show your hidden controls again
-
Oct 1st, 2003, 05:02 PM
#3
Thread Starter
Frenzied Member
Cool, thanks, good to know. I was just banging my head trying a work-around, which was messing with another control. Of course that didn't work either.
If I understand you correctly, a thread can mess with variables, but not controls?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|