Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5975755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:07:52+00:00 2026-05-22T21:07:52+00:00

I have a function: void foo() { string a=f; string b=t; Console.WriteLine(a+b); } I

  • 0

I have a function:

void foo() 
{
string a="f";
 string b="t";
 Console.WriteLine(a+b);
}

I also have some int(the functioin know it) that is the number of minutes to activate the function (lets call it COUNT). I want to do this function in a thread that will do the initialization part just one time, and then will print a+b every minute until the COUNT will end.
I also want that if the “stop” button will pushed i’ll stop the thread.
how can i do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:07:53+00:00Added an answer on May 22, 2026 at 9:07 pm

    First you create a Timer and set it to fire every minute (60 seconds, 60k ms).
    Next you add an Event handler to the Elapsed event (using +=).
    Third, the handler has this signature

    static void timer_Elapsed(object sender, ElapsedEventArgs e)
    

    so you get a reference to the timer from the sender parameter.

    Fourth, you have a static variable in the handler which counts how many times it fired.

    If it reaches the COUNT then you stop the timer form firing again (set its Enabled property to false). You can do this due to step three.
    If the count is less than COUNT then print what you need to print.
    If the count is 0 then do the initialization.

    Answer to question edit:
    Have the timer available in the program’s class. Then, in the Stop button’s event handler set the timer’s Enabled property to false.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function as such: int foo(void *val){ (char *)val=Long String; return 0;
Suppose I have method: void foo(const std::string& s); Can I create boost::function: boost::function<void(const std::string&)>
Let's assume we have a template function foo: template<class T> void foo(T arg) {
In C++, I have a function: void MyFunction(int p) { p=5; } Assume, I
I have a function called: void initializeJSP(string Experiment) And in my MyJSP.h file I
I have the following function void initBoard(int * board[BOARD_ROWS][BOARD_COLS]){ int z = 0; for(
Suppose I have a C function: void myFunction(..., int nObs){ int myVec[nObs] ; ...
I have the following intentionally trivial function: void ReplaceSome(ref string text) { StringBuilder sb
I know that string literals in C/C++ have static storage duration , meaning that
if i have a template function: template<class T, class S> void foo(T t, S

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.