EN / USD
32
of 76
TEP , The Engineering Projects , Image

syedzainnasir

TEP , The Engineering Projects , Rating 7.5 7.5 / 10
TEP , The Engineering Projects , Icon Level: Moderator
TEP , The Engineering Projects , Icon Joined: 20 Mar 2022
TEP , The Engineering Projects , Icon Last Active: 2:21 PM
TEP , The Engineering Projects , Icon Location: TEP , The Engineering Projects , Flag
TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon
How can I make a delay in Visual Studio 2010
TEP , The Engineering Projects , Calender Question: 20-Feb-2017
TEP , The Engineering Projects , Category In: Microsoft Visual Studio Projects
Hi all,



I need to know how can I make a delay of ~1msec in that platform.

beside the Order sleep() that gives me delay in seconds.



Thanks,
TEP , The Engineering Projects , Icon Answer: 1 TEP , The Engineering Projects , Icon Views: 150 TEP , The Engineering Projects , Icon Followers: 85
Small Bio
TEP , The Engineering Projects , Image

adiono

TEP , The Engineering Projects , Rating 7.5 7.5 / 10
TEP , The Engineering Projects , Icon Level: Moderator
TEP , The Engineering Projects , Icon Joined: 20 Mar 2022
TEP , The Engineering Projects , Icon Last Active: 2:21 PM
TEP , The Engineering Projects , Icon Location: TEP , The Engineering Projects , Flag
TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon TEP , The ENgineering Projects , Icon

RE:

How can I make a delay in Visual Studio 2010
TEP , The Engineering Projects , Calender Comment: 20-Feb-2017
TEP , The Engineering Projects , Category In: Microsoft Visual Studio Projects
[quote=Anita post_id=69 time=1487584009 user_id=70] Hi all,



I need to know how can I make a delay of ~1msec in that platform.

beside the Order sleep() that gives me delay in seconds.



Thanks, [/quote]
If you are building a console application then include windows header file and use sleep() function. Here is an example,
[code]// header files here #include <windows.h> int _tmain(int argc, _TCHAR* argv[]) { // code Sleep(1); return 0; }[/code]

If you are using Windows Application then follow this:

1. Define a timer ID on top of your cpp file
[code]#define MY_TIMER_ID (WM_USER + 200)[/code]

2. Declare a timer variable inside your class definition in header file
[code]class MainDlg : public CDialogEx { // defs UINT_PTR m_MyTimer; }[/code]

3. Implement your timer function,
[code]void MainDlg::OnTimer(UINT_PTR nIDEvent) { // use nIDEvent to detect if you have multiple timers // your code CDialogEx::OnTimer(nIDEvent); }[/code] 4. Start your timer for example in OnInitDialog() [code]BOOL MainDlg::OnInitDialog() { CDialogEx::OnInitDialog(); // Code m_MyTimer = SetTimer(MY_TIMER_ID, 1, NULL); }[/code] 5. Kill your timer when you are done. Example follows, [code]void MainDlg::OnClose( ) { // Code if (!KillTimer (m_MyTimer)) MessageBox(_T("Could not kill timer!")); CDialogEx::OnClose(); }[/code] Read More: [url=http://www.theengineeringprojects.com/2013/10/how-to-add-delay-in-microsoft-visual.html]HOW TO ADD A DELAY IN VISUAL STUDIO 2010[/url]
TEP , The Engineering Projects , Tick Correct Answer
Comment Bio
TEP , The Engineering Projects , Tags
PLC
Robot
STM32
Arduino
AI
ESP32
Ladder Logic
PLC Projects
Programming
Communicates STM32
PLC Projects
Communicates PLC
Font Style
Alignment
Indenting and Lists
Insert Media
Insert Items

Want to leave an answer!

Word Count :0 Draft Saved at 12:42 am.