Link to home
Start Free TrialLog in
Avatar of Julian_K
Julian_KFlag for Bulgaria

asked on

Problems with API and VB IDE/Compiler

Hello, experts.
I have the following situation:

1. I have made a usercontrol using VB.

2. The usercontrol uses timeSetEvent API function like so:
        m_hTmr = timeSetEvent(50, 5, AddressOf pTimerProc, &H0&, PERIODIC + CALLBACK_FUNCTION)
-.The pTimerProc is a procedure, declared in a Module in this project.
-.The pTimerProc refers back to the properties of the UserControl.

3. Everything works just fine while I'm testing it in the VB IDE.

The problem:
When I compile the source and test it, it crashes with "illegal operation" error.
The error comes out exactly when the timer "clicks"

I've heard that there are problems when implementing multi-threading in VB.
Is this the problem here, and how can I solve it?



Avatar of Julian_K
Julian_K
Flag of Bulgaria image

ASKER

By the way,
If I use SetTimer/KillTimer API functions instead, everything works fine. Grrrr!!!! (realy angry at Microsoft)
Avatar of marconovaro
marconovaro


Just as a curiosity (not an answer :-)): what's wrong with SetTimer, and why should you use timeSetEvent?
Just for your information: when I need a timer without a form (e.g. in a class), I usually use this:

http://www.vbaccelerator.com/home/VB/Code/Libraries/Subclassing/SSubTimer/article.asp

library (it's a subclassing helper, but a timer also).
M.
Hi, marconovaro.
About the SSubtimer class, I'm familiar with it.
The reason I don't use it in this application - it is too much overload to include it in a short-coded style program. What I mean - In that case I don't neet it's whole functionability, I just need a simple timer.

The difference between the SetTimer and timeSetEvent:
the timeSetEvent function sets a multimedia timer that runs in it's own thread, and the SetTimer function runs in the same thread.
Another difference is that the SetTimer function posts a message to the message queue, and timeSetEvent calls directly it's callback function.
Julian_K:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
Avatar of DanRollins
Julian_K, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Refund points and save as a 0-pt PAQ.

DanRollins -- EE database cleanup volunteer
Yep, that's ok with me.
Thanks, Dan Rollins.
ASKER CERTIFIED SOLUTION
Avatar of YensidMod
YensidMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial