Solved

Delphi events and processing

Posted on 2001-06-22
1
250 Views
Last Modified: 2010-04-06
What is the outcome when there are 2 different events calling the same procedure? will the procedure be pre-empted or will delphi create another instance of that procedure?

given:
 * 2 timers - TimerA and TimerB both enabled at the same time with the same time interval
 * 1 common procedure - Procedure Process_Data(code: string); (doing some lengthy processing)
    if code=A then process with parameter A
    if code=B then process with parameter B

sequence of events:
 * enable TimerA and TimerB
 * OnTimer of TimerA - call Process_Data('A');
   OnTimer of TimerB - call Process_Data('B');

how is the procedure going to proceed? will there be time-slicing? and if so, what are the priorities?
0
Comment
Question by:ttanyag
[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
1 Comment
 
LVL 20

Accepted Solution

by:
Madshi earned 100 total points
ID: 6217588
Windows timers work via messages. That means, as long as you don't handle messages, no timer is fired. That again means, if the first timer is fired, your callback function is called. If you don't do any message handling in this function, the second timer has to wait (even if the time is over), until your callback function is run through. Only then (hopefully someone else now handles messages, e.g. Application.Run does) the second timer is finally fired.

Delphi doesn't copy a procedure "instance" or code. If you create 2 timers that share the same callback function, then the same function is called. However, if you use Delphi's TTimer object (instead of pure win32 API), you can use "Self" to differ between the different parent timers.

Time slicing only applies to threads. Timers are no threads. One after the other is the mode, except if you're handling messages in the timer callback function, then the second timer may be fired, while the first is not fully handled yet. But then the first timer is "paused" as long as the 2nd is not finished.

Regards, Madshi.
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

735 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