?
Solved

Problems with API and VB IDE/Compiler

Posted on 2003-03-10
8
Medium Priority
?
248 Views
Last Modified: 2012-08-13
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
Comment
Question by:Julian_K
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 5

Author Comment

by:Julian_K
ID: 8101849
By the way,
If I use SetTimer/KillTimer API functions instead, everything works fine. Grrrr!!!! (realy angry at Microsoft)
0
 
LVL 6

Expert Comment

by:marconovaro
ID: 8101886

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
 
LVL 5

Author Comment

by:Julian_K
ID: 8102076
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
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!

 
LVL 5

Author Comment

by:Julian_K
ID: 8102128
Another difference is that the SetTimer function posts a message to the message queue, and timeSetEvent calls directly it's callback function.
0
 

Expert Comment

by:CleanupPing
ID: 8900408
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 9074634
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
 
LVL 5

Author Comment

by:Julian_K
ID: 9076858
Yep, that's ok with me.
Thanks, Dan Rollins.
0
 

Accepted Solution

by:
YensidMod earned 0 total points
ID: 9165958
Question is PAQ'd and points refunded.

YensidMod
Community Support Moderator @Experts Exchange
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question