SystemState StateChanged Subscription Must Occur on UI Thread?
flag
3 messages - Collapse all
/groups/adfetch?adid=bQodDxEAAABZdeKQQP_a-SDTkZLSX6YBFSRgCP-avRN4YT0eROC0jw
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
1.  jonfroehlich  
View profile  
 More options Oct 26 2007, 2:19 pm
Newsgroups: microsoft.public.dotnet.framework.compactframework
From: jonfroehlich <jonfroehl...@gmail.com>
Date: Fri, 26 Oct 2007 18:19:45 -0000
Local: Fri, Oct 26 2007 2:19 pm
Subject: SystemState StateChanged Subscription Must Occur on UI Thread?
The Microsoft.WindowsMobile.Status.SystemState class offers a great
way to track a number of interesting and useful device system states
(e.g., incoming phone calls, battery strength, etc.). However,
recently I observed that the SystemState.Changed += new
ChangeEventHandler(OnSystemStateChanged) subscription must be made
from the UI thread. Has anyone else run into this? I attempted to
write a console app that uses many of these system state
notifications; however, none of the events were actually occurring.
Once I switched to a form-based application, everything worked great.

Is this documented somehwere? If so, I couldn't find it. I am
programming in .NET CF 2 for Windows Mobile 5.0 devices.

http://msdn2.microsoft.com/en-us/library/microsoft.windowsmobile.stat...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
2.  <ctacke/>  
View profile  
 More options Oct 26 2007, 4:06 pm
Newsgroups: microsoft.public.dotnet.framework.compactframework
From: "<ctacke/>" <ctacke[at]opennetcf[dot]com>
Date: Fri, 26 Oct 2007 15:06:39 -0500
Local: Fri, Oct 26 2007 4:06 pm
Subject: Re: SystemState StateChanged Subscription Must Occur on UI Thread?
Most of those events come from windows messages being posted at a low level
(FileSystemWatcher works int he same way too).  If you never call
Application.Run, no message pump is ever created, so no windows messages are
ever dispatched.

I don't think I've ever seen it documented, but if you walk through the
aygshell source code in Platform Builder (which a lot of these come from
eventually), you'll see that's how they work.  I agree that it's a poor
choice, but it's how it was implemented.  The workaround is a very long,
tedious process (again, we've done it for file system notifications)  of
reimplementing the entire listening system, creating a hidden window for
your app or implementing a Run() that doesn't take a Form (like we did in
the SDF).

--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com

"jonfroehlich" <jonfroehl...@gmail.com> wrote in message

news:1193422785.905979.317920@v29g2000prd.googlegroups.com...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
3.  jonfroehlich  
View profile  
 More options Oct 26 2007, 8:46 pm
Newsgroups: microsoft.public.dotnet.framework.compactframework
From: jonfroehlich <jonfroehl...@gmail.com>
Date: Sat, 27 Oct 2007 00:46:24 -0000
Local: Fri, Oct 26 2007 8:46 pm
Subject: Re: SystemState StateChanged Subscription Must Occur on UI Thread?
Thanks Chris,

As always you provide super valuable feedback to the community. I
appreciate it.

Jon

On Oct 26, 1:06 pm, "<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google