Thanks for the notes, since this caused me to find a bug in the library.
There's no easy, ten-line solution to being notified of network events like
connect and disconnect, no. I tried four or five different schemes in
unmanaged code for our devices before settling on one that uses
point-to-point message queues and NDISUIO notifications. The
AdapterStatusMonitor class in OpenNETCF is a direct port from that unmanaged
code.
What you should do is, when a notification occurs, check the adapters which
are of interest to you and see if there's been a status change that you care
about. Ideally, just the notification messages should be enough to tell you
if an adapter has reestablished connection or lost it, but each adapter
sends messages to NDIS a bit differently and, depending on the
adapter/driver, you may get an unbalanced number of connect and disconnect
messages, or something along those lines, making it difficult to use the
information by itself to decide what the connection state is.
The latest source in the Vault for OpenNETCF includes the bug fix and
there's also a new Sample of using the status monitor.
Paul T.
"Nick Stineman" <(E-Mail Removed)> wrote in message
news:1AE73BAF-E601-4AC1-B7E1-(E-Mail Removed)...
> While I can appreciate that the OpenNETCF has lots of valuable tools, its
> adapter monitoring class is horrific. I've been attempting to accomplish
> using this for several weeks now & have since turned to posting questions
> here.
>
> I'm still convinced that monitoring for two events (wireless availability
> &
> cradling) cannot be that difficult. I know the device itself reacts to
> these
> actions so I simply need to include or append my logic into the devices
> already present event handlers.
>
> I'm looking for a solution outside of the OpenNETCF.NET namespace. While
> v.
> 1.1 did improve the adapter status area, It is still far from where many
> other of the namespaces currently are. I'm sure they'll iron out all of
> the
> wrinkles in time...but unfortunately I don't have the flexibility to wait
> on
> this project.
>
> Basically what I am looking for is a way to install some sort of
> application, class, system monitor, something onto the device that will
> monitor for the two connection states & when available automatically act
> accordingly.
>
> "Paul G. Tobey [eMVP]" wrote:
>
>> OK, it might be true that MSMQ is overkill. You could use a timer to
>> trigger calling the enumeration periodically, or you could create a
>> thread
>> in which there is a wait on an event. If the wait times out, it's time
>> to
>> enumerate the connections. If the event fires, that means that the
>> thread
>> should exit. Pretty standard stuff. OpenNETCF has lots of support for
>> threading, events, etc.
>>
>> The OpenNETCF.Net namespace has a lot of stuff for receiving
>> notifications
>> of change of state for adapters. That's probably your best bet for doing
>> something when wireless becomes connected. Look at AdapterStatusMonitor.
>> It's based on unmanaged code that I use on our devices to turn on an
>> indicator when wireless networking is connected.
>>
>> Paul T.
>>
>> "Nick Stineman" <(E-Mail Removed)> wrote in message
>> news:2B5B8D16-B925-4B48-BA8D-(E-Mail Removed)...
>> > First, Thank you both...both responses are helpful. However, I'm
>> > pretty
>> > green to smart device development & need to get a little more detail
>> > before
>> > diving into these issues. With regards to the MSMQ, it is on the
>> > device
>> > but
>> > all I need to do is monitor for connection states & then submit some
>> > T-SQL
>> > to
>> > the enterprise server. It seems that the MSMQ would be overkill for
>> > this.
>> > With regards to calling "RasEnumConnection P/Invoke"...I haven't gotten
>> > into
>> > Multithreading yet and perhaps this would be a good start. My question
>> > for
>> > this is how do I periodically call it?
>> >
>> > Isn't there a way that I can set the device up so that when the
>> > wireless
>> > connection is available it runs my sync procedure or application every
>> > 15
>> > minutes in the background? I've read some posts on how to kick things
>> > off
>> > when the device is cradled but where do I put this coding on the device
>> > &
>> > how
>> > do I get it to run as a system service?
>> >
>> > "Sergey Bogdanov" wrote:
>> >
>> >> Also you can periodically call RasEnumConnection P/Invoke in a
>> >> separate
>> >> thread. It will return list of all active RAS connections and its
>> >> names
>> >> that can be used to distinguish between one another. For example, for
>> >> an
>> >> active USB connection it will return connection with the name "`USB"
>> >> or
>> >> something.
>> >>
>> >> Best regards,
>> >> Sergey Bogdanov
>> >> http://www.sergeybogdanov.com
>> >>
>> >>
>> >> Nick Stineman wrote:
>> >> > I have a pretty basic question about the state of connectivity. My
>> >> > application will be a mostly disconnected application that (when
>> >> > available)
>> >> > needs to send & receive data from the enterprise server. The
>> >> > question
>> >> > I have
>> >> > is that how can I monitor (from the device) for a good Wireless
>> >> > connection,
>> >> > an ethernet connection, or a USB connection? The customer will be
>> >> > using all
>> >> > three situations to load & unload data from the device. Both the
>> >> > USB &
>> >> > Ethernet would be a cradle situation but the wireless would be a
>> >> > here &
>> >> > there
>> >> > situation. Thusly, my second question is how I can monitor for a
>> >> > wireless
>> >> > connection with an acceptable level of strength (30%). The users
>> >> > will
>> >> > be
>> >> > walking through areas all the time that have wireless access points.
>> >> > Sometimes these areas will be open for minutes & sometimes they'll
>> >> > only
>> >> > pass
>> >> > by them for a few seconds. I need to be able to monitor for any of
>> >> > the
>> >> > above
>> >> > 3 situations and begin my transfers when certain criteria are met.
>> >> > I've seem
>> >> > several posts on where to find more information on this subject but
>> >> > no
>> >> > posts
>> >> > on exactly how to write it in & implement it onto the handheld. I
>> >> > want
>> >> > this
>> >> > to happen automatically, behind the scenes without any user
>> >> > interaction. Any
>> >> > help would be greatly appreciated. Thanks!!
>> >>
>>
>>
>>