Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

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?



0
Julian_K
Asked:
Julian_K
1 Solution
 
Julian_KAuthor Commented:
By the way,
If I use SetTimer/KillTimer API functions instead, everything works fine. Grrrr!!!! (realy angry at Microsoft)
0
 
marconovaroCommented:

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.
0
 
Julian_KAuthor Commented:
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.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Julian_KAuthor Commented:
Another difference is that the SetTimer function posts a message to the message queue, and timeSetEvent calls directly it's callback function.
0
 
CleanupPingCommented:
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?
0
 
DanRollinsCommented:
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
0
 
Julian_KAuthor Commented:
Yep, that's ok with me.
Thanks, Dan Rollins.
0
 
YensidModCommented:
Question is PAQ'd and points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now