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
Solved

timers

Posted on 1998-06-05
8
186 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 30 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
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 opening and reading files in the C programming language.

839 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