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

  • SEARCH
  • Home
  • 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 6600007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:33:58+00:00 2026-05-25T18:33:58+00:00

I want to identify specific mysql db column value using timer. For example, I

  • 0

I want to identify specific mysql db column value using timer.
For example, I have 6 timers and in database I have a column named flag, and its values are 100, 100, 100, 103, 103, 106, 107, 107, 107, 108, 108, 109. I want:

1st timer to work with three 100 values,  
2nd timer to work with two 103,   
3rd timer to work with one 106 value,  
4th timer to work with three 107 values,   
5th timer to work with two 108 values and  
6th timer to work with one 109 values.

How do I assign these values (100, 103, 106) to my timers?

  • 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-25T18:33:58+00:00Added an answer on May 25, 2026 at 6:33 pm

    What you want to do is to have a single method with flag parameters that will be called every time one of the timers is elapsed. To achieve this without creating a lot of similar event handler methods you can use lambda statements:

    void PrepareTimers() {
        var timer1 = new Timer(TimerAction, 100, 5000, 0);   
        var timer2 = new Timer(TimerAction, 103, 5000, 0);
    
        // etc
    }
    

    There I create a few timers with 5000 ms interval and make sure that TimerAction is called with the parameter I want for this particular timer. The method itself could be along these lines:

    void TimerAction(object flag) {        
        SqlCommand cmd = new SqlCommand(
            "SELECT * FROM Customers WHERE flag = @flag", _connection);
        SqlParameter param  = new SqlParameter();
        param.ParameterName = "@flag";
        param.Value = flag;
        cmd.Parameters.Add(param);
    
        // execute query
    }
    

    In my example I just use a parameterized select statement to read all the rows with correct flag. You’ll probably want to do some update or delete logic, but the idea is the same – you want to do a parameterized SQL query and pass the parameter’s value in method’s argument.

    Note that PrepareTimers implementation that I gave is very simple and has to be rewritten using a loop if you need to use more than 2 timers:

    List<int> _flagValues = new List<int> { 100, 103, 106, 107, 108, 109 };
    
    void PrepareTimers(List<int> flagValues) {
        foreach(int flagValue in flagValues) {
            var timer = new Timer(TimerAction, flagValue, 5000, 0);
        }
    } 
    

    EDIT: I made a few edits to make sure I use System.Threading.Timer insted of System.Timers.Timers (see discussion). Sorry for the mess.

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

Sidebar

Related Questions

I have multiple ImageViews in a UIScrollView and I want to identify the specific
I want to identify disk in c++ in my windows application. For example: I
I want to identify from where a visitor coming to my webpage.Is there anyways
I'm building a C# application, and I want to identify users by their username.
I want to quickly identify if a key is present in an array, to
I want to quickly identify all writable files in the directory. What is the
Suppose I want to put objects that identify a server into a stl set
I want to know how, from a controller action, I could identify the area
I'm using SQL Server and I want to use identity constraint in it I
I want to use GenerationType.IDENTITY for primary keys in my production MySQL system. But

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.