Solved

Delphi events and processing

Posted on 2001-06-22
1
252 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month10 days, 23 hours left to enroll

628 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