<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Atomic Monks, LLC — Brother Erryn's VB Timer Alternatives]]></title>
	<link rel="self" href="http://forums.atomicmonks.com/feed/atom/topic/1054/"/>
	<updated>2009-12-31T02:29:16Z</updated>
	<generator>PunBB</generator>
	<id>http://forums.atomicmonks.com/topic/1054/brother-erryns-vb-timer-alternatives/</id>
		<entry>
			<title type="html"><![CDATA[Re: Brother Erryn's VB Timer Alternatives]]></title>
			<link rel="alternate" href="http://forums.atomicmonks.com/post/6735/#p6735"/>
			<content type="html"><![CDATA[<p>Wow, that&#039;s been a while. I guess you&#039;re talking about my old articles on GPWiki (also posted here)? Those were written years ago, back in the days of .NET 1.0...today I would use something else. If you&#039;re wanting something to automatically fire at regular intervals, consider using the <a href="http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatchertimer.aspx">DispatcherTimer</a> (.NET 3.0) class.</p><p>Here&#039;s an example of it in use:<br /></p><div class="codebox"><pre><code>timer.Interval = New TimeSpan(0, 0, 1)
timer.IsEnabled = True
AddHandler timer.Tick, AddressOf UpdateUI
timer.Start()</code></pre></div><p>If you just want to get an accurate measure of how much time has passed since the last time you checked, use the <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx">Stopwatch</a> (.NET 2.0) class.</p><p>An example of using the Stopwatch:<br /></p><div class="codebox"><pre><code>Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();

... do stuff ...

stopWatch.Stop();
// Get the elapsed time as a TimeSpan value.
TimeSpan ts = stopWatch.Elapsed;</code></pre></div><p>Does this sort of answer your question? You didn&#039;t really say anything about what you&#039;re trying to do with your timer in this case.</p>]]></content>
			<author>
				<name><![CDATA[Brother Erryn]]></name>
				<uri>http://forums.atomicmonks.com/user/2/</uri>
			</author>
			<updated>2009-12-31T02:29:16Z</updated>
			<id>http://forums.atomicmonks.com/post/6735/#p6735</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Brother Erryn's VB Timer Alternatives]]></title>
			<link rel="alternate" href="http://forums.atomicmonks.com/post/6734/#p6734"/>
			<content type="html"><![CDATA[<p>Hi, Brother Erryn!</p><p>I am JamRoll, an intermediate programmer in VB.&nbsp; I am creating a game of my own (no name...yet).&nbsp; I am currently using the clunky timer control provided by vb express 2008.&nbsp; I have viewed your posts regarding timers...but I am confused.&nbsp; I would have posted to yours posts, but it says I don&#039;t have permission to...</p><p>Currently I have</p><div class="codebox"><pre><code>    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)  _
      Handles Timer1.Tick
          Invalidate()
    End Sub</code></pre></div><p>Um...how do I incorporate your method into my program???<br />Or am I just way off base here?&nbsp; LOL <img src="http://forums.atomicmonks.com/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /></p><p>Sincerely,</p><p>JamRoll</p>]]></content>
			<author>
				<name><![CDATA[JamRoll]]></name>
				<uri>http://forums.atomicmonks.com/user/1208/</uri>
			</author>
			<updated>2009-12-30T23:41:22Z</updated>
			<id>http://forums.atomicmonks.com/post/6734/#p6734</id>
		</entry>
</feed>

