Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

timers

Posted on 1998-06-05
8
Medium Priority
?
191 Views
Last Modified: 2010-04-15
I want to abort a function call after sixty seconds...how do I do it?   This is on the NT Platform.  

I already tried using the SetTimer Call, but this doesn't abort the already called function.

thanks
0
Comment
Question by:mulshine
8 Comments
 
LVL 2

Expert Comment

by:kinkajou
ID: 1251121
I created a simple application that displays a splash screen (that little screen that comes up while an application is initializing) and quits execution after 10 seconds. I used SetTimer (), displayed the splash dialog and when the call came to KillTimer () I had my over ridden KillTimer function send a call to the dialog telling it to close its self. Would that be possible in your case?
0
 
LVL 11

Accepted Solution

by:
alexo earned 120 total points
ID: 1251122
Aborting a function call is possible in two different ways.

1) If the function is designed to be abortable, it should periodically test a flag (can be set using the timer routine).

2) A general function can be aborted if you start it as a thread (see _beginthread(), _beginthreadex() and functions and CreateThread() API).  You can then kill the thread externally using the TerminateThread() API.  Note that the thread will not be given a chance to perform any cleanup.

0
 
LVL 6

Expert Comment

by:WxW
ID: 1251123
You probably send a WM_CLOSE message to the dialog box with the timer . That cannot be done with functions , because functions do not have a message loop .
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 11

Expert Comment

by:alexo
ID: 1251124
>> functions do not have a message loop.
Right, but they can have one.
0
 
LVL 2

Expert Comment

by:kinkajou
ID: 1251125
The method I used does not have a message loop in a dialog but killed the dialog when the KillTimer() function was called. Much simpler than what everyone proposes. I would explain it further it mulshine thinks that it may solve the problem.
0
 
LVL 11

Expert Comment

by:alexo
ID: 1251126
kinkajou, mulshine asked for "aborting a function", not a dialog.

0
 
LVL 1

Expert Comment

by:meessen
ID: 1251127
You have to create a thread to be able to abort it from outside.
You would wait for the thread execution completion in normal situation or kill the thread if not yet done after 60 seconds.

Or you have to use a a variable you need to poll and you can set with the timer interrupt function.




0
 
LVL 11

Expert Comment

by:alexo
ID: 1251128
Which is exactly what I suggested in my answer... :-)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

963 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