Search Results

Search found 1610 results on 65 pages for 'timer'.

Page 2/65 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • C# how to use timer ?

    - by Meko
    Hi. I made a student check_list program thats using bluetooth adapter searches students cell phones bluetooth and checks that are they present or not and saves students informtion with date in table on data base.all them works gereat.But I want to make it automatic that I will put my program on some computer like works as an server and program will make search every lessons start time like 08.30 , 10.25 ... My question is how to use timer? I know how to use timer but How can I use it on every lessons start time?I have table that includes start time of lessons. Also am I have to stop timer after search ends?And If I stop timer could I re-run timer againg? And one additional question that how can I track that new students come or some body left class room?

    Read the article

  • Change timer intervall in windows service

    - by AyKarsi
    I have timer job inside a windows service, for which the intervall should be incremented when errors occur. My problem is that I can't get the timer.Change Method to actually change the intervall. The "DoSomething" is always called after the inital interval.. This is probably something simple .. Code follows: protected override void OnStart(string[] args) { //job = new CronJob(); timerDelegate = new TimerCallback(DoSomething); seconds = secondsDefault; stateTimer = new Timer(timerDelegate, null, 0, seconds * 1000); } public void DoSomething(object stateObject) { AutoResetEvent autoEvent = (AutoResetEvent)stateObject; if(!Busker.BitCoinData.Helpers.BitCoinHelper.BitCoinsServiceIsUp()) { secondsDefault += secondsIncrementError; if (seconds >= secondesMaximum) seconds = secondesMaximum; Loggy.AddError("BitcoinService not available. Incrementing timer to " + secondsDefault + " s",null); stateTimer.Change(seconds * 100, seconds * 100); return; } else if (seconds > secondsDefault) { // reset the timer interval if the bitcoin service is back up... seconds = secondsDefault; Loggy.Add ("BitcoinService timer increment has been reset to " + secondsDefault + " s"); } // do the the actual processing here }

    Read the article

  • java timer on current instance

    - by hspim
    import java.util.Scanner; import java.util.Timer; import java.util.TimerTask; public class Boggle { Board board; Player player; Timer timer; boolean active; static Scanner in = new Scanner(System.in); public Boggle() { board = new Board(4); timer = new Timer(); } public void newGame() { System.out.println("Please enter your name: "); String line = in.nextLine(); player = new Player(line); active = true; board.shuffle(); System.out.println(board); timer.schedule(new timesUP(), 20000); while(active) { String temp = in.nextLine(); player.addGuess(temp); } } public void endGame() { active = false; int score = Scoring.calculate(player, board); System.out.println(score); } class timesUP extends TimerTask { public void run() { endGame(); } } public static void main(String[] args) { Boggle boggle = new Boggle(); boggle.newGame(); } } I have the above class which should perform a loop for a given length of time and afterwards invoke an instance method. Essentially I need the loop in newGame() to run for a minute or so before endGame() is invoked on the current instance. However, using the Timer class I'm not sure how I would invoke the method I need on the current instance since I can't pass any parameters to the timertasks run method? Is there an easy way to do this or am I going about this the wrong way? (note: this is a console project only, no GUI) ========== code edited I've changed the code to the above following the recommendations, and it works almost as I expect however the thread still doesnt seem to end properly. I was the while loop would die and control would eventually come back to the main method. Any ideas?

    Read the article

  • .NET Windows Service with timer stops responding

    - by Biri
    I have a windows service written in c#. It has a timer inside, which fires some functions on a regular basis. So the skeleton of my service: public partial class ArchiveService : ServiceBase { Timer tickTack; int interval = 10; ... protected override void OnStart(string[] args) { tickTack = new Timer(1000 * interval); tickTack.Elapsed += new ElapsedEventHandler(tickTack_Elapsed); tickTack.Start(); } protected override void OnStop() { tickTack.Stop(); } private void tickTack_Elapsed(object sender, ElapsedEventArgs e) { ... } } It works for some time (like 10-15 days) then it stops. I mean the service shows as running, but it does not do anything. I make some logging and the problem can be the timer, because after the interval it does not call the tickTack_Elapsed function. I was thinking about rewrite it without a timer, using an endless loop, which stops the processing for the amount of time I set up. This is also not an elegant solution and I think it can have some side effects regarding memory. The Timer is used from the System.Timers namespace, the environment is Windows 2003. I used this approach in two different services on different servers, but both is producing this behavior (this is why I thought that it is somehow connected to my code or the framework itself). Does somebody experienced this behavior? What can be wrong? Edit: I edited both services. One got a nice try-catch everywhere and more logging. The second got a timer-recreation on a regular basis. None of them stopped since them, so if this situation remains for another week, I will close this question. Thank you for everyone so far. Edit: I close this question because nothing happened. I mean I made some changes, but those changes are not really relevant in this matter and both services are running without any problem since then. Please mark it as "Closed for not relevant anymore".

    Read the article

  • I need help with a timer for a text based game, i need to include a mysql query to it, but not sure how.

    - by Hijumper
    i would like to add a mysql query somewhere in my timer code so that everytime it restarts then 1 item would be added to the database, i can get it to show how many items you have gotten since the timer has been running, but im not quite sure how to add it into a mysql database, any help would be appreciated :D heres my timer code thus far: <head> <script type="text/javascript"> var c=10; var mineCount = 0; var t; var timer_is_on=0; function timedCount() { document.getElementById('txt').value = c; c = c - 1; if (c <= -1) { mineCount++; var _message = "You have mined " + mineCount + " iron ore" + (((mineCount > 1) ? "s" : "") + "!"); document.getElementById('message').innerHTML = _message; startover(); } } function startover() { c = 10; clearTimeout(t); timer_is_on=0; doMining(); } function doMining() { if (!timer_is_on) { timer_is_on = true; t = setInterval(function () { timedCount(); }, 1000); } } </script> <SPAN STYLE="float:left"> <form> <input type="button" value="Mining" onClick="doMining()"> <input type="text" id="txt"> </form> </SPAN> <html> <center> <div id='message'></div>

    Read the article

  • Game Timer In C++

    - by user1870398
    I need to be able to find out how many milliseconds since that last update. Is there any way I can find it out with time rather then a thread that counts like I did below? #include <iostream> #include<windows.h> #include<time.h> #include<process.h> using namespace std; int Timer = 0; int LastTimer = 0; bool End = false; void Update(int Ticks) { } void UpdateTimer() { while (true) { LastTimer = Timer; Timer++; Sleep(1); if (End) break; } } int WINAPI WinMain(HINSTANCE par1, HINSTANCE par2, LPSTR par3, int par4) { _beginthread(UpdateTimer, 0, NULL); while(true) { if (Timer == 1000) Timer = 0; Update(Timer - LastTimer); } }

    Read the article

  • Problem re-factoring multiple timer countdown

    - by jowan
    I create my multiple timer countdown from easy or simple script. entire code The problem's happen when i want to add timer countdown again i have to declare variable current_total_second CODE: elapsed_seconds= tampilkan("#time1"); and variable timer who set with setInterval.. timer= setInterval(function() { if (elapsed_seconds != 0){ elapsed_seconds = elapsed_seconds - 1; $('#time1').text(get_elapsed_time_string(elapsed_seconds)) }else{ $('#time1').parent().slideUp('slow', function(){ $(this).find('.post').text("Post has been deleted"); }) $('#time1').parent().slideDown('slow'); clearInterval(timer); } }, 1000); i've already know about re-factoring and try different way but i'm stack to re-factoring this code i want implement flexibelity to it.. when i add more of timer countdown.. script do it automatically or dynamically without i have to add a bunch of code.. and the code become clear and more efficient.. Thanks in Advance

    Read the article

  • Showing "Failed" for a SharePoint 2010 Timer Job Status

    - by Damon
    I have been working with a bunch of custom timer jobs for last month.  Basically, I'm processing a bunch of SharePoint items from the timer job and since I don't want the job failing because of an error on one item, so I'm handing errors on an item-by-item basis and just continuing on with the next item.  The net result of this, I soon found, is that my timer job actually says it ran successfully even if every single item fails.  So I figured I would just set the "Failed" status on the timer job is anything went wrong so an administrator could see that not all was well. However, I quickly found that there is no way to set a timer job status.  If you want the status to show up as "Failed" then the only way to do it is to throw an exception.  In my case, I just used a flag to store whether or not an error had occurred, and if so the the timer job throws a an exception just before existing to let the status display correctly.

    Read the article

  • How to create a JQuery Clock / Timer

    - by Ganesh Shankar
    I have a simple quiz application and I want display a nice timer / clock at the top of the page which shows the user how long they've been going for. (If I could somehow show them a timer for Total Quiz Time and also a second one for This Question Time that would be even cooler but I should be able to figure out how to do myself that once I've got one timer working. My question is: What's a nice, easy way to show a simple timer / clock using JQuery? (straight JS is also ok) I know how to check time, but how do I get incrementing seconds? My own searches keep leading me to JQuery plugins (I want to roll my own) and also "event timers" which are not what I'm looking for...

    Read the article

  • Incremental Timer

    - by Donal Rafferty
    I'm currently using a Timer and TimerTask to perform some work every 30 seconds. My problem is that after each time I do this work I want to increment the interval time of the Timer. So for example it starts off with 30 seconds between the timer firing but I want to add 10 seconds to the interval then so that the next time the Timer takes 40 seconds before it fires. Here is my current code: public void StartScanning() { scanTask = new TimerTask() { public void run() { handler.post(new Runnable() { public void run() { wifiManager.startScan(); scanCount++; if(SCAN_INTERVAL_TIME <= SCAN_MAX_INTERVAL){ SCAN_INTERVAL_TIME = SCAN_INTERVAL_TIME + SCAN_INCREASE_INTERVAL; t.schedule(scanTask, 0, SCAN_INTERVAL_TIME); } } }); }}; Log.d("SCAN_INTERVAL_TIME ** ", "SCAN_INTERVAL_TIME ** = " + SCAN_INTERVAL_TIME); t.schedule(scanTask, 0, SCAN_INTERVAL_TIME); } But the above gives the following error: 05-26 11:48:02.472: ERROR/AndroidRuntime(4210): java.lang.IllegalStateException: TimerTask is scheduled already Calling cancel or purge doesn't help. So I was wondering if anyone can help me find a solution? Is a timer even the right way to approach this?

    Read the article

  • WPF Dispatcher timer tick freezes my application

    - by Nebo
    I've got a little problem using WPF Dispatcher Timer. On each timer tick my application freezes for a moment (until timer tick method finishes). This is my code: private DispatcherTimer _Timer = new DispatcherTimer(); _Timer.Tick += new EventHandler(_DoLoop); _Timer.Interval = TimeSpan.FromMilliseconds(1500); _Timer.Start(); Is there any way to avoid this and have my application run smoothly?

    Read the article

  • Windows.Forms.Timer instance and UI threads

    - by David Rutten
    I have a custom control whose primary purpose is to draw data. I want to add a ScheduleUpdate(int milliSeconds) method to the control which will force an update X milliseconds from now. Since this is all GUI land, I should be using a Windows.Forms.Timer, but how does this timer instance know which thread it belongs to? What if ScheduleUpdate() is called from a non-UI thread? Should I construct the timer in the Control constructor? Or perhaps the Load event? Or is it safe to postpone construction until I'm inside ScheduleUpdate()? I know there are some very similar questions about this already, but I don't have a Timer component on my control, I'm constructing it on a when-it's-needed basis.

    Read the article

  • Threading.Timer invokes asynchronously many methods

    - by Dimitar
    Hi guys! Please help! I call a threading.timer from global.asax which invokes many methods each of which gets data from different services and writes it to files. My question is how do i make the methods to be invoked on a regular basis let's say 5 mins? What i do is: in Global.asax I declare a timer protected void Application_Start() { TimerCallback timerDelegate = new TimerCallback(myMainMethod); Timer mytimer = new Timer(timerDelegate, null, 0, 300000); Application.Add("timer", mytimer); } the declaration of myMainMethod looks like this: public static void myMainMethod(object obj) { MyDelegateType d1 = new MyDelegateType(getandwriteServiceData1); d1.BeginInvoke(null, null); MyDelegateType d2 = new MyDelegateType(getandwriteServiceData2); d2.BeginInvoke(null, null); } this approach works fine but it invokes myMainMethod every 5 mins. What I need is the method to be invoked 5 mins after all the data is retreaved and written to files on the server. How do I do that?

    Read the article

  • C# timer getting fired before their interval time

    - by Swati Ghaisas
    Hi, We're getting following problem while using system.threading.timer ( .net framework 2.0 ) from a Windows service. There are around 12 different timer objects.. Each timer has due time and interval. This is set correctly. It is observed that after 3 to 4 hours, the timers start signalling before their interval elapses. For example if the timer is supposed to signal at 4:59:59, it gets signalled at 4:59:52, 7 seconds earlier. Can someone tell me what is the cause for this behavior and what is the solution for that ? Thanks, Swati

    Read the article

  • Using Timer only once

    - by zaidwaqi
    Hi, I want to use a timer only once, at 1 second after the initialization of my main form. I thought the following would have a message box saying "Hello World" just once, but actually a new message box says "Hello World" every one second. Why so? I had put t.Stop() in the tick event. Also, do I need to dispose the timer somehow to avoid memory leakage? Timer t = new Timer(); t.Interval = 1000; t.Tick += delegate(System.Object o, System.EventArgs e) { MessageBox.Show("Hello World"); t.Stop(); }; t.Start(); Please help and show if there is a better way of doing this? Thanks.

    Read the article

  • AS3: Synchronize Timer event to actual time?

    - by Nebs
    I plan to use a timer event to fire every second (for a clock application). I may be wrong, but I assume that there will probably be a (very slight) sync issue with the actual system time. For example the timer event might fire when the actual system time milliseconds are at 500 instead of 0 (meaning the seconds will be partially 'out of phase' if you will). Is there a way to either synchronize the timer event to the real time or get some kind of system time event to fire when an second ticks in AS3? Also if I set a Timer to fire every 1000 milliseconds, is that guaranteed or can there be some offset based on the application load? These are probably negligible issues but I'm just curious. Thanks.

    Read the article

  • How to pause the timer in c#?

    - by Jay
    I have a timer in my code and the interval is 10s When the timer elapsed, I will do some checking, and it may takes more than 10s for checking and some update jobs. However, if I didn't stop the timer, seems the checking will execute every 10s ... If I call the stop(), seems the timer cannot be start again ... ie something like: protected void timer_elapsed(object sender, EventArgs args) { __timer.Stop(); //Some checking here more than 10s __timer.Start(); } I just want another 10s to check again after the before checking is done. anyone can help?

    Read the article

  • Starting timer from another project

    - by raj
    I have to projects in my .net windows forms, in one form(1st Project) i have timer control already running. On some request i want to start that timer from the form1 of (second project). If we are creating new object in second project for the 1st project(Which is currently in running thread) we will not be able to start the timer for the current instance. How can we access the current running instance from my 2nd project. Please suggest me some method

    Read the article

  • Threading.Timer vs. Forms.Timer

    - by Jekke
    The short form of this question: When, if ever, is it appropriate to use the Forms.Timer in a multithreaded WinForms application? More specifically, I am architecting an application that uses multiple System.Threading.Timers to launch processes asynchronously, check queues containing the results of those asynchronous processes, and update the statistics to be shown by the application's main form. In an application like that, is it appropriate to use a Forms.Timer to actually check the application statistics and draw them to the main form or would that just throw a wrench into the application's smooth running?

    Read the article

  • XP boot timer=> set, but does nothing?

    - by mark
    My PC has XP Pro and the boot.ini file looks like this: [boot loader] timeout=30 default=multi(0)disk(0)rdisk(0)partition(2)\windows [operating systems] C:\CMDCONS\BOOTSECT.DAT="Microsoft Windows Recovery Console" /cmdcons multi(0)disk(0)rdisk(0)partition(2)\windows="eXPee Pro" /noexecute=optin /fastdetect Up until about a week ago it would just time-out and boot normally. I haven't made any hardware changes at all. Now, when the system boots it just sits there and waits for me to hit -enter-. I've searched all over for explanations & possible causes, but found nothing which seems to relate. Anyone here have any idea what may have caused the timer to simply quit working like that ? (BTW, the system clock works just as it ever did and keeps time precisely.) Thanks.

    Read the article

  • How to use Timer broadcast on Multi-Processor system with linux 3.10?

    - by kevin.ji
    Hardware: ARM Cortex-A9 * 2 Software: linux-3.10.0 The platform has 2 cores of arm cortex-a9. Item CONFIG_LOCAL_TIMERS is not set in linux menuconfig. I want to use only one hardware timer to supply tick for all cpu. Interrupts looks like: CPU0 CPU1 57: 6697 0 GIC timer 81: 213 0 GIC uart-pl011 103: 0 0 GIC gmac0 104: 0 0 GIC gmac1 IPI0: 0 1 CPU wakeup interrupts IPI1: 0 0 Timer broadcast interrupts IPI2: 967 866 Rescheduling interrupts IPI3: 0 0 Function call interrupts IPI4: 1 2 Single function call interrupts IPI5: 0 0 CPU stop interrupts IPI6: 0 0 CPU backtrace Err: 0 Timer broadcast interrupts counter does not add. And it looks like that cpu1 does not work at all.But this method works well with linux-3.4, and the interrupt info looks as below in linux-3.4: # cat /proc/interrupts CPU0 CPU1 57: 8596 0 GIC timer 81: 91 0 GIC uart-pl011 103: 0 0 GIC gmac0 104: 0 0 GIC gmac1 IPI0: 0 8560 Timer broadcast interrupts IPI1: 884 1020 Rescheduling interrupts IPI2: 0 0 Function call interrupts IPI3: 0 6 Single function call interrupts IPI4: 0 0 CPU stop interrupts IPI5: 0 0 CPU backtrace Err: 0 The count of Timer broadcast interrupts is adding. And all of cpus work well. I don't know why. Any answer is welcome. :)

    Read the article

  • Algorithm for count-down timer that can add on time

    - by Person
    I'm making a general timer that has functionality to count up from 0 or count down from a certain number. I also want it to allow the user to add and subtract time. Everything is simple to implement except for the case in which the timer is counting down from some number, and the user adds or subtracts time from it. For example: (m_clock is an instance of SFML's Clock) float Timer::GetElapsedTime() { if ( m_forward ) { m_elapsedTime += m_clock.GetElapsedTime() - m_elapsedTime; } else { m_elapsedTime -= m_elapsedTime - m_startingTime + m_clock.GetElapsedTime(); } return m_elapsedTime; } To be a bit more clear, imagine that the timer starts at 100 counting down. After 10 seconds, the above function would look like 100 -= 100 - 100 + 10 which equals 90. If it was called after 20 more seconds it would look like 90 -= 90 - 100 + 30 which equals 70. This works for normal counting, but if the user calls AddTime() ( just m_elapsedTime += arg ) then the algorithm for backwards counting fails miserably. I know that I can do this using more members and keeping track of previous times, etc. but I'm wondering whether I'm missing some implementation that is extremely obvious. I'd prefer to keep it as simple as possible in that single operation.

    Read the article

  • Timer in java ,time difference problem

    - by javatechi
    I want to create a timer for my app. The sample code is shown below. When the method datetwo() is called the same time in milliseconds is shown as there in the main method. Please help me out with this import java.util.Date; import java.util.Timer; public class TimerChe { Timer timer; static Date date = new Date(); static Date date2 = new Date(); public static void timerMethod(){ new Thread() { public void run() { try { while (true) { sleep(10000); datetwo(); } } catch (InterruptedException ex) { } } }.start(); } public static void datetwo() { System.out.println ("OK, It's time to do something!") ; System.out.println("The Time is " + date2.getTime() + " milliseconds since 1970/01/01"); } public static void main(String args[]) throws Exception { System.out.println("The Time is " + date.getTime() + " milliseconds since 1970/01/01" ); System.out.println ("Schedule something to do in the mean time.") ; timerMethod(); } }

    Read the article

  • Timer in Java swing

    - by Yesha
    I'm trying to replace Thread.sleep with a java swing timer as I hear that is much better for graphics. Before, I had something set up like this, but it was interfering with the graphics. while(counter < array.size){ Thread.sleep(array.get(counter).startTime); //do first task Thread.sleep(array.get(counter).secondTime); //do second task Thread.sleep(array.get(counter).thirdTime); //do third task counter++ } Now, I'm trying to replace each Thread.sleep with one of these and then I have the actual events that happen after this, but it does not seem to be waiting at all. int test = array.get(counter).time; ActionListener taskPerformer = new ActionListener(){ public void actionPerformed(ActionEvent evt){ } }; Timer t = new Timer(test, taskPerformer); t.setRepeats(false); t.start(); Basically, how do I ensure that the program will wait without giving it any code to execute inside of the timer? Thank you!

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >