F
Fredrik Jagenheim
Hi,
I have a application which recieves events asynchronously.
The event processing is done as such:
=09=09Thread.new do
=09=09=09ev =3D WIN32OLE_EVENT.new(@provider, '_IDataProviderEvents')
=09=09=09ev.on_event {|*args| event_handler(*args)}
=09=09=09ev.on_event("OnDataAvailable") { |datapacket| received(datapacket)=
}
=09=09=09loop do
=09=09=09=09WIN32OLE_EVENT.message_loop
=09=09=09=09sleep(0.1)
=09=09=09end
=09=09end
I have to use the sleep, or else the CPU runs at 100%. However, this
limits me to 10 messages/second, which may be more.
I'm experimenting with other values for sleep, but I have a feeling
there's a better way.
Can't I just ask message_loop to hang until there is a message?
//F
I have a application which recieves events asynchronously.
The event processing is done as such:
=09=09Thread.new do
=09=09=09ev =3D WIN32OLE_EVENT.new(@provider, '_IDataProviderEvents')
=09=09=09ev.on_event {|*args| event_handler(*args)}
=09=09=09ev.on_event("OnDataAvailable") { |datapacket| received(datapacket)=
}
=09=09=09loop do
=09=09=09=09WIN32OLE_EVENT.message_loop
=09=09=09=09sleep(0.1)
=09=09=09end
=09=09end
I have to use the sleep, or else the CPU runs at 100%. However, this
limits me to 10 messages/second, which may be more.
I'm experimenting with other values for sleep, but I have a feeling
there's a better way.
Can't I just ask message_loop to hang until there is a message?
//F