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. Millisecond Timer Period

Millisecond Timer Period

Scheduled Pinned Locked Moved C#
csharphardwarequestion
5 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.
  • S Offline
    S Offline
    ScotDolan
    wrote on last edited by
    #1

    I am currently writing UDP socket class to control a device. I created a class that has a UDP socket. I have blocking function that I uses the socket to transmit a packet to the device. The function than needs receieve the response packet/packets from devices. However, if no valid response is not recieved in x period of millisecond the function needs to timeout. I am having difficulties creating a way to calculate millisecond periods. In the past i use to use GetTickCount(); How do i accomplish this i C# Scott

    Scott Dolan Jernie Corporation Engineering & Manufacturing Software, Hardware, & Enclosures

    S P D 3 Replies Last reply
    0
    • S ScotDolan

      I am currently writing UDP socket class to control a device. I created a class that has a UDP socket. I have blocking function that I uses the socket to transmit a packet to the device. The function than needs receieve the response packet/packets from devices. However, if no valid response is not recieved in x period of millisecond the function needs to timeout. I am having difficulties creating a way to calculate millisecond periods. In the past i use to use GetTickCount(); How do i accomplish this i C# Scott

      Scott Dolan Jernie Corporation Engineering & Manufacturing Software, Hardware, & Enclosures

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      Environment.TickCount[^]? You could also try using QueryPerformanceCounter[^].

      Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

      1 Reply Last reply
      0
      • S ScotDolan

        I am currently writing UDP socket class to control a device. I created a class that has a UDP socket. I have blocking function that I uses the socket to transmit a packet to the device. The function than needs receieve the response packet/packets from devices. However, if no valid response is not recieved in x period of millisecond the function needs to timeout. I am having difficulties creating a way to calculate millisecond periods. In the past i use to use GetTickCount(); How do i accomplish this i C# Scott

        Scott Dolan Jernie Corporation Engineering & Manufacturing Software, Hardware, & Enclosures

        P Offline
        P Offline
        Pr teek B h
        wrote on last edited by
        #3

        Create a timer and use the following event:

        int tickCount = 0;
        void timer1_Tick(object sender, EventArgs e) {
        tickCount = tickCount + 1;
        }

        I haven't tested the code out, but it should work. Hope this helps :) Prateek

        1 Reply Last reply
        0
        • S ScotDolan

          I am currently writing UDP socket class to control a device. I created a class that has a UDP socket. I have blocking function that I uses the socket to transmit a packet to the device. The function than needs receieve the response packet/packets from devices. However, if no valid response is not recieved in x period of millisecond the function needs to timeout. I am having difficulties creating a way to calculate millisecond periods. In the past i use to use GetTickCount(); How do i accomplish this i C# Scott

          Scott Dolan Jernie Corporation Engineering & Manufacturing Software, Hardware, & Enclosures

          D Offline
          D Offline
          DaveyM69
          wrote on last edited by
          #4

          The .net timers are not all equal and do not all perform as you might expect, especially in terms of resolution. Luc Pattyn has a great article on timers here[^] that may help - if not, it's a good read anyway :-D

          Dave
          BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
          Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

          P 1 Reply Last reply
          0
          • D DaveyM69

            The .net timers are not all equal and do not all perform as you might expect, especially in terms of resolution. Luc Pattyn has a great article on timers here[^] that may help - if not, it's a good read anyway :-D

            Dave
            BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
            Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

            P Offline
            P Offline
            Pr teek B h
            wrote on last edited by
            #5

            wow, i didn't know that. Thanks for sharing :)

            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