在Linux和Windows报警功能 - >无法找到一个Windows相当于 - > C [英] alarm function on Linux and Windows -> can't find a equivalent for Windows -> C

查看:309
本文介绍了在Linux和Windows报警功能 - >无法找到一个Windows相当于 - > C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在已经工作了一段时间,在Linux和做了一些C程序,现在我需要建立一个应用程序的Windows,但不是容易找到报警功能(在signal.h中找到)的替代品..

I have worked for some time now on Linux and done some C programs, and now I need to build an app for windows but is not being easy to find a replacement for the alarm function (found on signal.h)...

问题是,在Linux中,当你设置报警标志作为SIGALRM(如果没记错),什么操作系统要做的是,当闹钟响起来执行某些功能。
例如:

The thing is, in Linux, when you set the alarm flag as SIGALRM (if not mistaken), what the OS is going to do is to execute some function when the alarm goes off. Example:

signal(SIGALRM, myfunc);
alarm (2);

这是怎么回事这个例子中发生的是操作系统将要调用的函数MYFUNC每2秒(在Windows将是毫秒可能,但不介意细节现在)。

What is going to happen on this example is the OS is going to call the function myfunc every 2 seconds (in windows is going to be miliseconds probably, but don't mind that detail right now).

我搜索过一段时间,如何做同样的窗口(仅在使用ATM WINDOWS.H中),但我无法找到一个替代(搜查数千MSDN上的时间),以及在Windows上存在在signal.h中没有SIGALRM标志.....

I've searched for some time how to do the same on windows (only using windows.h atm) but I can't find a replacement for that (searched thousands of times on msdn), and, on windows there is no SIGALRM flag on the signal.h.....

我可以用C用什么做同样的行为与SIGALRM标志报警?(换句话说,一个功能,允许通过报警或类似执行其他功能)。

What can I use in C to do the same behaviour as the alarm with the SIGALRM flag?(In other words, a function that allows to execute another function using an alarm or similar).

推荐答案

检查MSDN为的timeSetEvent 。这是不完全一样的报警,但可能是足够接近。

Check the MSDN for timeSetEvent. It's not exactly the same as alarm, but may be close enough.

这篇关于在Linux和Windows报警功能 - >无法找到一个Windows相当于 - > C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆