Click to See Complete Forum and Search --> : Doevents problem


thomascheung
March 20th, 2001, 04:56 AM
Hi, this the first time I post here. And I really need help for my program.
I use winsock to build an end-to-end transmission system. At the receiver side, there's a media player control to display media files. During the media files are displaying, there may be data coming from the sender and the receiver will deal with the data frames received during dataarrival. But at the same time the media player is also running. I don't want it stopped during processing the incoming data, so I added a "doevents" at the dataarrival so that the media player won't stopped when receiving data. But if the data I send is too big ( >5MB), the receiver will suddenly display "out of stack place". Can anybody tell me how to deal with this problem?

Clearcode
March 20th, 2001, 05:17 AM
When you added a DoEvents you open the possibility of the code being reentrant - that is to say, your Subroutine can be called whilst it is already called.
This soon eats up your stack space.
The solution is to ringfence the doevents so that it cannot fire again and again thus:

static bReentrant as Boolean

If Not bReentrant then
bReentrant = true
DoeEvents
bReentrant = false
End If




HTH,
Duncan

Incidentally, IMHO DoEvents is a bit of a cludge fix. If you have two things you want to run at the same time you need to run them on their own threads. Look for source on MultiThreading on this site.


-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com