Results 1 to 5 of 5

Thread: [RESOLVED] What timer to use.

  1. #1

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    814

    Resolved [RESOLVED] What timer to use.

    I am writing a new project tonight I thought I may have a go at writing a program to close process, for example when Notepad.exe is opened, it will inform the user to enter a password if correct run app else close it, well simple

    I was just wondering should I go with for checking the process I thought of a normal timer, but I am unsure someone said to me maybe use threading
    I not had much experience on threading so I don’t know were to start on that. also I herd VB.NET has 3 timers a normal one a server one and a threading one.
    what one do you think will be the best to use for my app, Remember it be running in the background all the time.

    Thanks

  2. #2
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: What timer to use.

    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  3. #3

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    814

    Re: What timer to use.

    wow that a lot of reading to do tho went down to the bottom of the page the System.Threading.Timer seems a good one to look into.
    Anyway we see how my app turns out thanks for the link I Bookmark it for latter reading.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: What timer to use.

    Quote Originally Posted by BenJones View Post
    wow that a lot of reading to do
    That's how you learn, reading enough information to get the full picture instead of asking for specific answers to specific questions that provide no real understanding outside a very specific set of circumstances.

    As for the right Timer, it's rare that you should have to use a Threading.Timer. The Timers.Timer is a wrapper for that anyway so, unless you specifically need a very lightweight Timer, don't use a Threading.Timer. As the name suggests, the Windows.Forms.Timer is intended for use in WinForms apps. It raises its Tick event on the UI thread. The Timers.Timer can also raise its Elapsed event on the UI thread in a WinForms app but, by default, it will raise events on a thread pool thread, which means that multiple event handlers can execute simultaneously and other work can be done at the same time too.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    814

    Re: What timer to use.

    Quote Originally Posted by jmcilhinney View Post
    That's how you learn, reading enough information to get the full picture instead of asking for specific answers to specific questions that provide no real understanding outside a very specific set of circumstances.

    As for the right Timer, it's rare that you should have to use a Threading.Timer. The Timers.Timer is a wrapper for that anyway so, unless you specifically need a very lightweight Timer, don't use a Threading.Timer. As the name suggests, the Windows.Forms.Timer is intended for use in WinForms apps. It raises its Tick event on the UI thread. The Timers.Timer can also raise its Elapsed event on the UI thread in a WinForms app but, by default, it will raise events on a thread pool thread, which means that multiple event handlers can execute simultaneously and other work can be done at the same time too.
    Yes it was a lot of reading some went over my head and it was late , I am just used to the old VB6 one timer, now we have 3, anyway thanks for the info I try it out.
    Last edited by BenJones; Jan 22nd, 2013 at 05:25 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width