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 7615487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:39:19+00:00 2026-05-31T02:39:19+00:00

I’m working on an application which shows a random movie quote once in a

  • 0

I’m working on an application which shows a random movie quote once in a minute, but I can’t get the code to work.

I’m using a UserControl which contains of a label to show the quote, and in it’s Page_Load I want to instantiate “Quote”. The constructor starts a timer which calls the function that’s randomize a quote once in a minute, and returns it to the Page_Load and shows it in the Label.Text.

The line with the timer gives me the following error message: ‘System.Timers.Timer’ does not contain a constructor that takes 4 arguments’, which for me makes no sense?

public class Quote {
    List<string> movieQuote;

    private string RandomQuote(object state) {

        movieQuote.Add("quote1");
        movieQuote.Add("quote2");
        movieQuote.Add("quote3");
        movieQuote.Add("quote");

        Random randNr = new Random();
        int aRandomPos = randNr.Next(1, movieQuote.Count);

        string quote = movieQuote[aRandomPos];

        return quote;
    }

    public Quote() {
         movieQuote = new List<string>();
         Timer timer = new Timer(RandomQuote, null, TimeSpan.Zero, TimeSpan.FromMinutes(1));
    }
}
  • 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-31T02:39:21+00:00Added an answer on May 31, 2026 at 2:39 am

    First off, you need to understand that there are a few different Timer classes built into .NET, with slightly different behaviors based on the most likely requirements of users of a timer from a particular library. System.Timers.Timer truly doesn’t have a constructor with four arguments. What you probably wanted was a System.Threading.Timer.

    Also, I should tell you that Timers in a web environment are just bad. Bad, bad, bad. The reason why is because of the ASP.NET lifecycle. The short of it is that an instance of your codebehind class only exists in memory for as long as it takes to render the HTML page. After that, it’s released and GCed. When a new request comes in, for a form event or whatever, a new instance of the class is created. The upshot is that a Timer created during Page_Load will go out of scope and be disposed of long before it fires the Tick event.

    Instead, what you want is an AJAX-y area of your page which uses a Javascript Timeout to trigger a call to the server which will generate a new random quote. That will be returned in XML format to the client which can write it into the DOM of the page, without a full postback. There are AJAX interop controls you can add to your page to streamline this (it will trigger a full postback, but only actually redraw the area bounded by an AJAX UpdatePanel), or you can give your page a simple SOAP or JSON service call that will return the string without any other server-side logic having to run.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.