Threading and GUI Issue

  • Thread starter Thread starter Howard Swope
  • Start date Start date
H

Howard Swope

In my application, running on PocketPC, I have two TrackBar controls on a
form. Also in this application I have a socket which will send the value
from the trackBar1 to a server (running on my desktop pc) and receive a
message from the server indicating a value change. I use this to set the
value of trackBar2. When I do this the application locks up.

I have performed several tests that point to the fact that there is a
threading problem.

1. I have the value change of trackBar1 set the value of trackBar2
directly (no socket communication). There is no problem here, everything is
done on the same thread and the movement of trackBar1 is mirrored on
trackBar2

2. I have the value change of trackBar1 just call to the socket, but I do
nothing when I receive a message from the server indicating a value change.
Nothing locks up.

3. I use another application to send a value change to the server and
trackBar2 shows the changes fairly responsively.

There seems to be some type of threading error happening. Any thoughts about
how I might go about tracking down the problem and fixing it?
 
Thanks Daniel. That explains it.

However, my experience is slightly different than that described in your
blog. You mention, "The issue and solution are the same for both full and
compact frameworks; the difference is that, although the desktop seems to be
forgiving (sometimes updating from non-GUI thread works), the CF certainly
isn't: every time you try it, the result is an application that is
hung/frozen/locked up. If you see this on your device, start looking for the
said problem."

I have found that my CF application behaved for the most part until I
performed many activities in rapid succession in the UI that triggered
updates on the secondary thread. Then it locked. If rapid updates on the
secondary thread were triggered by another application, it didn't lock up.

I am seeing behavior similar to the way you describe the desktop
framework... interesting.

Anyway, thanks again.
 
Glad control invoke solves it for you.

Regarding my comment of "every time": that is true for my device, 100% lock
up. Not sure if it is a custom_WinCE_device versus PPC issue but since the
solution is the same it is largely academic :-)

BTW, CF 2.0 has a better story while still different to the desktop v2...
that story is also on my blog (linked from the one you read)...

Cheers
Daniel
 
Back
Top