[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

Can someone explain in simple terms how to create an event to detect a property change?

(Mike Mitchell)

6/24/2011 10:41:00 AM

I'm using an NNTP control that has an IsReadable property that is set
to True when data is waiting.

Instead of polling in a loop for IsReadable = True I wondered if I
could somehow set up an event handler that triggers when the property
goes from False to True.

Trouble is, I'm a novice when it comes to roll-your-own event handlers
and all the explanations I've found on the web are as clear as mud.

Thanks!

MM
5 Answers

Dee Earley

6/24/2011 11:06:00 AM

0

On 24/06/2011 11:40, MM wrote:
> I'm using an NNTP control that has an IsReadable property that is set
> to True when data is waiting.
>
> Instead of polling in a loop for IsReadable = True I wondered if I
> could somehow set up an event handler that triggers when the property
> goes from False to True.
>
> Trouble is, I'm a novice when it comes to roll-your-own event handlers
> and all the explanations I've found on the web are as clear as mud.

You can't without polling. The control however may offer an event that
reports the same information.

--
Dee Earley (dee.earley@icode.co.uk)
i-Catcher Development Team
http://www.icode.co.uk...

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)

Schmidt

6/24/2011 11:31:00 AM

0

Am 24.06.2011 12:40, schrieb MM:

> I'm using an NNTP control that has an IsReadable property that is set
> to True when data is waiting.
>
> Instead of polling in a loop for IsReadable = True I wondered if I
> could somehow set up an event handler that triggers when the property
> goes from False to True.
>
> Trouble is, I'm a novice when it comes to roll-your-own event handlers
> and all the explanations I've found on the web are as clear as mud.

In case you have the source of the Control in question,
then you will have to look, using a Control-CodeModule-wide
search, for all occurences, where the internal m_IsReadable,
or mIsReadable (whatever) Boolean-Variable is changed in the
NNTP-source-code (e.g. by searching for the string:
'm_IsReadable ='

If you're lucky, you will find only one place,
where the Value of this internal Prop-Variable
is set/changed - and that's the place where you
(after the line with m_IsReadable =)
would need to place a:
RaiseEvent ReadableStateChanged()

Then you will only have to add an additional line
at the top of the COntrol-CodeModule:
Public Event ReadableStateChanged()

and you're done.

Olaf

(Mike Mitchell)

6/24/2011 2:48:00 PM

0

On Fri, 24 Jun 2011 12:05:34 +0100, Deanna Earley
<dee.earley@icode.co.uk> wrote:

>On 24/06/2011 11:40, MM wrote:
>> I'm using an NNTP control that has an IsReadable property that is set
>> to True when data is waiting.
>>
>> Instead of polling in a loop for IsReadable = True I wondered if I
>> could somehow set up an event handler that triggers when the property
>> goes from False to True.
>>
>> Trouble is, I'm a novice when it comes to roll-your-own event handlers
>> and all the explanations I've found on the web are as clear as mud.
>
>You can't without polling. The control however may offer an event that
>reports the same information.

It does. OnRead. But this doesn't fire, even though the documentation
says it should when the control is in non-blocking mode
(Blocking=False).

An explanation from tech support:

"....the async events are only generated for article transfers and
won't fire for custom commands because of how the control decides to
wire up the event handler."

Yet when I try the freeware SocketWrench to do exactly the same thing
as the NNTP control, OnRead triggers just fine.

The so-called "custom commands" in my case are: GROUP and XHDR --
hardly custom!

So I was thinking ...hmm...wonder whether I could set up my own "event
detector"? There's an IsReadable property that could be tested.

MM

(Mike Mitchell)

6/24/2011 7:11:00 PM

0

On Fri, 24 Jun 2011 12:05:34 +0100, Deanna Earley
<dee.earley@icode.co.uk> wrote:

>On 24/06/2011 11:40, MM wrote:
>> I'm using an NNTP control that has an IsReadable property that is set
>> to True when data is waiting.
>>
>> Instead of polling in a loop for IsReadable = True I wondered if I
>> could somehow set up an event handler that triggers when the property
>> goes from False to True.
>>
>> Trouble is, I'm a novice when it comes to roll-your-own event handlers
>> and all the explanations I've found on the web are as clear as mud.
>
>You can't without polling. The control however may offer an event that
>reports the same information.

A plea from me: if you have a few minutes spare, can you read the
relevant thread (it's not very long) at
http://forums.catalyst.com/viewtopic.php?f=6&... and tell me if I'm
being nit-picky?

Olaf, too, if you have time.

Thanks.

MM

(Mike Mitchell)

6/24/2011 8:32:00 PM

0

On Fri, 24 Jun 2011 20:10:48 +0100, MM <kylix_is@yahoo.co.uk> wrote:

>On Fri, 24 Jun 2011 12:05:34 +0100, Deanna Earley
><dee.earley@icode.co.uk> wrote:
>
>>On 24/06/2011 11:40, MM wrote:
>>> I'm using an NNTP control that has an IsReadable property that is set
>>> to True when data is waiting.
>>>
>>> Instead of polling in a loop for IsReadable = True I wondered if I
>>> could somehow set up an event handler that triggers when the property
>>> goes from False to True.
>>>
>>> Trouble is, I'm a novice when it comes to roll-your-own event handlers
>>> and all the explanations I've found on the web are as clear as mud.
>>
>>You can't without polling. The control however may offer an event that
>>reports the same information.
>
>A plea from me: if you have a few minutes spare, can you read the
>relevant thread (it's not very long) at
>http://forums.catalyst.com/viewtopic.php?f=6&... and tell me if I'm
>being nit-picky?
>
>Olaf, too, if you have time.
>
>Thanks.
>
>MM

Forget the previous post! I've since fixed the problem. A lack of RTFM
on my part was its cause (although my excuse is that tech support
didn't pick it up, either).

Anyway, OnRead event is now triggering and I can sleep easy tonight.

MM