Wireless Communication Library Support Forum

Legacy => Wireless Communication Library => Topic started by: badbod99 on June 30, 2009, 04:47:51 PM

Title: WCL in console application
Post by: badbod99 on June 30, 2009, 04:47:51 PM
I've created a console application trying to use the Discovery function, however I am not receiving the events OnDiscoveryStarted and OnDiscoveryComplete.  I have blocked the thread using something like:

while (_scanning) Thread.Sleep(1);

Using dotNet events this would not normally cause an issue, but I assume there is some internal messaging going on which is not managing to callback.

Is it possible to use WCL in a console application?  How can I get around this issue?

Thanks
Title: Re: WCL in console application
Post by: Mike Petrichenko on June 30, 2009, 06:04:57 PM
Hi,

it was discussed lots of time on this forum. WCL uses windows messages internally to delivery events between threads and to get notifications from low-leve drivers. Your application (even console) must have message loop.
Title: Re: WCL in console application
Post by: badbod99 on June 30, 2009, 06:52:49 PM
This is what I thought, but after considerable searching I couldn't find a clear answer, most seemed to be about threading.  For example... A search on the forum for "console" returned no results.

Should it work with a Windows service in that case?  I assume not, unless I use a hidden window of some sort.  Do you have any example of this?
Title: Re: WCL in console application
Post by: Mike Petrichenko on July 01, 2009, 09:52:25 AM
It works in any application which has message loop. I have no sample for that right now but try to write one later.
Title: Re: WCL in console application
Post by: Mike Petrichenko on July 02, 2009, 05:16:13 PM
Please, take a look at this article: http://msdn.microsoft.com/en-us/magazine/cc163417.aspx
It describes how to add message loop to any application (especially to console one)

Russian version: http://msdn.microsoft.com/ru-ru/magazine/cc163417.aspx
Title: Re: WCL in console application
Post by: badbod99 on July 02, 2009, 05:19:09 PM
That's great, thanks.

Might be a good idea to integrate this logic directly into your .Net wrapper, would make it a bit more simple to use.
Title: Re: WCL in console application
Post by: Mike Petrichenko on July 02, 2009, 05:38:41 PM
I agree with you and will try to do so.