-
December 30th, 2008, 02:19 AM
#1
Monitoring a Variable [VB.net 2008]
Hi
I am trying to make a program the will monitor if the certain variable changes.
lets say if the default value is 0, the program will just listen, but when the value changes to 1. something will happen.
here is what i have thought
Code:
Do Until Exit_button is clicked
If val != 0 Then
Execute Statement
End if
Loop
how can i do this? in VB.net if its just that, the program wont let me do anything. since it is busy with the endless loop.
thanks
-
December 30th, 2008, 05:47 AM
#2
Re: Monitoring a Variable [VB.net 2008]
The UI is handled by a seperate thread, so you have to either have
Code:
application.doevents
inside your loop or place your loop code in a background worker thread.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
0100 1101 0110 1001 0110 0011 0110 1000 0110 0001 0110 0101 0110 1100 0010 0000 0100 0101 0110 1100 0110 1100 0110 0101 0111 0010
-
January 3rd, 2009, 11:54 PM
#3
Re: Monitoring a Variable [VB.net 2008]
Thanks, i tried done the background component, now i need to produce a status report while the event is being handled like. let say every 1 second. in a texbox it will say the word "Listening" to it and it will refresh oh let say 2 seconds.
since i can't just change the property of a textbox in the DoWork event of the BGW component, and the RunWorkerComplete event will only be initiated as soon as the task is done, or i purposely cancel the task. how do i go around this?
-
January 4th, 2009, 01:32 AM
#4
Re: Monitoring a Variable [VB.net 2008]
BGW has a FLAG that is used as a DELEGATE, which can be used to initiate code in both threads.
-
January 4th, 2009, 03:19 AM
#5
Re: Monitoring a Variable [VB.net 2008]
is there a sample code so that i can have a idea on how to do that?
-
January 4th, 2009, 06:20 PM
#6
Re: Monitoring a Variable [VB.net 2008]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|