Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Design Forum > Web Design & Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Web Design & Programming Discussion of web design, and server-side & client-side scripting

Reply
 
LinkBack Thread Tools
Old 12-30-2008, 12:03 AM   #1 (permalink)
Registered User
 
Join Date: Aug 2008
Location: Philippines
Posts: 45
OS: WinXP Pro sp3


Send a message via Yahoo to Solidad Send a message via Skype™ to Solidad
Exclamation Monitoring a Variable

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.
Solidad is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 12-30-2008, 06:36 AM   #2 (permalink)
Registered User
 
Join Date: Dec 2008
Posts: 43
OS: Windows Vista x64


Re: Monitoring a Variable

The reason it does this is because the application is divided into threads, you are executing an endless loop on the form thread, which causes it to lock up. What you need to do is create a sub thread (multi-threading) for the application. Take a look at this, maybe it will help:
http://www.dreamincode.net/code/snippet875.htm

Alternatively, you could use a Timer and set the interval to 1 sec and in the timer tick's code you can handle what happens if it changes.

Side note, why not just use an on click method for the button instead of waiting for the button to be clicked by using loops?
daniel142005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 12-30-2008, 09:11 AM   #3 (permalink)
Registered User
 
Join Date: Aug 2008
Location: Philippines
Posts: 45
OS: WinXP Pro sp3


Send a message via Yahoo to Solidad Send a message via Skype™ to Solidad
Re: Monitoring a Variable

since i am monitoring a parallel port. when the value on that status port changes. it should run a event and send a signal to the motors drivers. the trigger is a laser and a photo sensor when the laser light is blocked a change in the status port will happen. since we don't know when will that happen it should be monitored.
Solidad is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 12-30-2008, 01:48 PM   #4 (permalink)
Registered User
 
Join Date: Dec 2008
Posts: 43
OS: Windows Vista x64


Re: Monitoring a Variable

Ah, i just kinda glanced at the code, yeah try running the loop in another thread with the background worker and see if that helps you any. The timer is probably easier to implement but is kind of a work around and may cause problems later on.

Last edited by daniel142005; 12-30-2008 at 01:49 PM.
daniel142005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 01-03-2009, 10:05 PM   #5 (permalink)
Registered User
 
Join Date: Aug 2008
Location: Philippines
Posts: 45
OS: WinXP Pro sp3


Send a message via Yahoo to Solidad Send a message via Skype™ to Solidad
Re: Monitoring a Variable

i try running the background worker component, and now i need to periodically to produce a report. like a text box text that says "Monitoring" every lets say 1 sec. since BGW uses a different thread i can't just change the values of the texbox, and the RunComplete event of the BGW will only happen when i cancel or finish the task, how can it be overcome?
Solidad is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 01-05-2009, 01:55 PM   #6 (permalink)
Registered User
 
Join Date: Dec 2008
Posts: 43
OS: Windows Vista x64


Re: Monitoring a Variable

Your going to need to use delegates and invokes to communicate between threads. Check here: http://addressof.com/blog/archive/2005/02/10/1287.aspx it has some tutorials on Threading in VB .NET.
daniel142005 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 08:25 AM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85