Multithreaded Pulse Train

Posted on 2007-10-09
Last Modified: 2013-11-26
I was wondering the most efficient way to produce a "pulse train" in a .NET program.
I need an adjustable on off pulse, typically 1000ms on 500 ms off to drive a flashing output. My thought was to use VB.NET Background worker and put the thread to sleep for ech of the time and use the update progress method o flip a bolean that the rest of my program can read.

Is there a more efficient way?

(.NET 2.0 Framework)
Question by:moldie
    LVL 23

    Expert Comment

    by:Jens Fiederer
    How accurate do you need to be?  A thread that takes action between sleeps would be the standard way to do this...but be aware that Windows is NOT a realtime OS, and there is no reason to expect these "pulses" to be very accurate.  If a few ms either way makes a difference, you are going to have to use an external device.

    Author Comment

    The time interval is not critical as I only flash an external lamp to warn an operator so he wouldn't care if it's 500 or 800ms flash. I did however wanted a slow flash rate and a quicker flash rate say 1500/500 and 300/3000 on/off and was a bit concerned about how much loading I would place onto the processor, as my application is a "bolt on" to a heavier application. If there is a better wat or is this aproach acceptable?
    LVL 23

    Accepted Solution

    You are in good shape.   A thread that spends practically all its time sleeping is very little stress on the system.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now