Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Timer in C#

Timer in C#

Scheduled Pinned Locked Moved C#
csharptoolstutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mimimimilaw
    wrote on last edited by
    #1

    Dear All, I would like the time the execution time for a script. But I did not get any idea for using timer. Any Example for counting the time of running time in a simple way? Thanks!:)

    C D 2 Replies Last reply
    0
    • M mimimimilaw

      Dear All, I would like the time the execution time for a script. But I did not get any idea for using timer. Any Example for counting the time of running time in a simple way? Thanks!:)

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      To time something, grab DateTime.Now before and after the operation

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      1 Reply Last reply
      0
      • M mimimimilaw

        Dear All, I would like the time the execution time for a script. But I did not get any idea for using timer. Any Example for counting the time of running time in a simple way? Thanks!:)

        D Offline
        D Offline
        Developer611
        wrote on last edited by
        #3

        Hi there . There is an another way to do it . Try to use Thread in Threading namespace . Something like following code : private void StartThread() { Thread thd1 = new Thread(new ThreadStart(Your_Function()); thd1.Start(); // After start thread , your function will be execute on per second. // You can set your thread start time . } private void Your_Function() { // Do something ... } Important : If your function get any parameter Use ParameterizedThreadStart delegate instead of ThreadStart DMASTER

        L 1 Reply Last reply
        0
        • D Developer611

          Hi there . There is an another way to do it . Try to use Thread in Threading namespace . Something like following code : private void StartThread() { Thread thd1 = new Thread(new ThreadStart(Your_Function()); thd1.Start(); // After start thread , your function will be execute on per second. // You can set your thread start time . } private void Your_Function() { // Do something ... } Important : If your function get any parameter Use ParameterizedThreadStart delegate instead of ThreadStart DMASTER

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          :confused: where is the timing information ?

          Developer611 wrote:

          your function will be execute on per second

          what is the meaning of this ? the new thread will start immediately and execute the method once...

          Luc Pattyn [Forum Guidelines] [My Articles]


          this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups