473,396 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

coding for timer in consile application of codeblock

1
below is the coding..but its still have error. the error is at "public ref class timer"..need help..
(timer in win32)

Expand|Select|Wrap|Line Numbers
  1. #include <windows.h>
  2. #include <winsock.h>
  3. #include <stdio.h>
  4.  
  5. class timeGetTime
  6. public ref class Timer :
  7.  public Component
  8. {
  9. private:
  10.    static System::Windows::Forms::Timer^ myTimer = gcnew System::Windows::Forms::Timer;
  11.    static int alarmCounter = 1;
  12.    static bool exitFlag = false;
  13.  
  14.    // This is the method to run when the timer is raised.
  15.    static void TimerEventProcessor( Object^ /*myObject*/, EventArgs^ /*myEventArgs*/ )
  16.    {
  17.       myTimer->Stop();
  18.  
  19.       // Displays a message box asking whether to continue running the timer.
  20.       if ( MessageBox::Show( "Continue running?", String::Format( "Count is: {0}", alarmCounter ), MessageBoxButtons::YesNo ) == DialogResult::Yes )
  21.       {
  22.  
  23.          // Restarts the timer and increments the counter.
  24.          alarmCounter += 1;
  25.          myTimer->Enabled = true;
  26.       }
  27.       else
  28.       {
  29.  
  30.          // Stops the timer.
  31.          exitFlag = true;
  32.       }
  33.    }
  34.  
  35.  
  36. public:
  37.    static void Main()
  38.    {
  39.  
  40.       /* Adds the event and the event handler for the method that will
  41.                 process the timer event to the timer. */
  42.       myTimer->Tick += gcnew EventHandler( TimerEventProcessor );
  43.  
  44.       // Sets the timer interval to 5 seconds.
  45.       myTimer->Interval = 5000;
  46.       myTimer->Start();
  47.  
  48.       // Runs the timer, and raises the event.
  49.       while ( exitFlag == false )
  50.       {
  51.  
  52.          // Processes all the events in the queue.
  53.          Application::DoEvents();
  54.       }
  55.    }
  56.  
  57. };
  58.  
  59. int main()
  60. {
  61.    Class1::Main();
  62. }
Jun 15 '12 #1
0 1877

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mike | last post by:
Hi, I need help writing a script that checks to see how long an asp application has been active on the server. The basic logic is - If the timer and application exceed 60 minutes then refresh the...
1
by: Wayne Carlaw | last post by:
We'd like to begin coding a schedule application, much like Outlook and wanted some opinions on what the best approach to this project would be. Does anyone have any experience pulling appointments...
14
by: Mathieu | last post by:
Hi all, I just want to know how to use a System.Windows.Forms.Timer in class. I know how to use it on a form, but I don't know how to "put" a timer in a class (DLL) Thx !!!
10
by: Bob | last post by:
Okay, I've done this for years but now I'm going to question it just because this idea has been at the back of my head since I started using DotNet... My WinForms app queries a database every 60...
2
by: John Devlon | last post by:
Hi everyone.... I'm trying to make something work... When I launch a new form, the application has to quit after a few seconds... I searched the net for some hours and I can't find any...
2
by: zamir.khan | last post by:
Hello all, New to the groups, sorry if this the wrong forum/etiquette. I am coding a c++ application that requires the use of a timer-triggered event handler. I decided to use the timer provided...
3
by: Arturo Buonanni | last post by:
Hello, I'm coding a web application using ASP.NET 2.0. Is there a way in wich I can enumerate all active sessions and have information about these sessions? Thanks.
4
by: Max | last post by:
This may be an elementary question but it's something I have not encountered in about 10 years writing code in VB 5 / 6 I have a timer that using the API checks if there has been a change to one...
2
by: Amit Dedhia | last post by:
Hi I am developing a scientific application which has moderate level image processing involved. In my application, there is a main application form which invokes another form. When this form...
2
by: Oliver Witt | last post by:
Hi, I am coding a c++ application that is supposed to be capable of altering large text files. I want to use sed to do this. So I need to know how I can start sed from within the c++ program and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.