VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 307,003 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,973 people online right now. Registration is fast and FREE... Join Now!




[2008] Updating Form Variables during Thread

 

[2008] Updating Form Variables during Thread

Tim A

1 Sep, 2009 - 02:51 PM
Post #1

New D.I.C Head
*

Joined: 3 Apr, 2008
Posts: 32

I'm not sure exactly how to describe this. In VB6, there was a Timer command. I could create a variable of type Timer and loop until the current value for Timer exceeded the initial plus a given amount of time. This allowed me to update form variables while the timing loop was executing. How can I do something similar in .NET?

Here is a sample of the VB6 code:

CODE
    Dim StartTimer As Double

    StartTimer = Timer
    Do

        Call Sleep(100)
        txtFinalRefValue.Text = DVMread(SystemSetup.RefChannel)
        
    Loop While (Timer < (StartTimer + LeakTestTime)) And DoEvents()


User is offlineProfile CardPM
+Quote Post


PsychoCoder

RE: [2008] Updating Form Variables During Thread

1 Sep, 2009 - 03:24 PM
Post #2

I Code, Therefore I am
Group Icon

Joined: 26 Jul, 2007
Posts: 14,919



Thanked: 517 times
Dream Kudos: 11525
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
Moved to VB.NET smile.gif
User is offlineProfile CardPM
+Quote Post

CapeCAD

RE: [2008] Updating Form Variables During Thread

1 Sep, 2009 - 05:23 PM
Post #3

D.I.C Head
**

Joined: 10 Aug, 2009
Posts: 60



Thanked: 14 times
My Contributions
QUOTE(Tim A @ 1 Sep, 2009 - 04:51 PM) *

I'm not sure exactly how to describe this. In VB6, there was a Timer command. I could create a variable of type Timer and loop until the current value for Timer exceeded the initial plus a given amount of time. This allowed me to update form variables while the timing loop was executing. How can I do something similar in .NET?

Here is a sample of the VB6 code:

CODE
    Dim StartTimer As Double

    StartTimer = Timer
    Do

        Call Sleep(100)
        txtFinalRefValue.Text = DVMread(SystemSetup.RefChannel)
        
    Loop While (Timer < (StartTimer + LeakTestTime)) And DoEvents()



I believe what you are looking for is:

CODE

Application.DoEvents()

User is offlineProfile CardPM
+Quote Post

Tim A

RE: [2008] Updating Form Variables During Thread

2 Sep, 2009 - 06:54 AM
Post #4

New D.I.C Head
*

Joined: 3 Apr, 2008
Posts: 32

I guess I just didn't realize that the Timer function still existed in .NET. Here's the final code...

CODE

     Dim StartTimer As Double
     Dim LeakTestTime As Double = 5

     StartTimer = DateAndTime.Timer
     Do

        Threading.Thread.Sleep(100)
        txtFinalRefValue.Text = DVMread(SystemSetup.RefChannel)
        Application.DoEvents()
     Loop While (DateAndTime.Timer < (StartTimer + LeakTestTime))

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 06:32AM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month