473,387 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

suspicious delay when changing textbox properties??

Hi all,

I'm developing a Visual Basic 2005 application to communicate with an
I2C device. I recently decided to add an i2c status bar. The status
bar is just a textbox with the following properties:

When I2C communication active:
Public Sub i2c_active()
statusBar.Text = "Exchanging Data..."
statusBar.BackColor = Drawing.Color.Red
End Sub

When I2C communication is idle:
Public Sub i2c_idle()
statusBar.Text = "IDLE"
statusBar.BackColor = Drawing.Color.Lime
End Sub

Ideally, the above properties are changed before and after the
get_i2c_data function. For example:
i2c_active()
get_i2c_data()
i2c_idle()

The problem is that the textbox properties for i2c_active() don't
change until after the get_i2c_data() function finishes. For example,
if I execute
i2c_active()
get_i2c_data()
the textbox doesn't turn red and display "Executing Data..." until
after it has already retrieved the data from the i2c device. This is
completely pointless!

There is some sort of delay between when the i2c_active() function
executes and when I see the textbox properties change. To debug, I
tried just executing the i2c_active() function and the textbox
properties change instantaneously. I need to have the textbox
properties change instantaneously when the get_i2c_data() function is
included. I'm not sure how to get this working. Any suggestions
would be appreciated.

Thanks,
-weg22

Aug 30 '07 #1
4 1628
On Aug 30, 8:24 am, we...@drexel.edu wrote:
Hi all,

I'm developing a Visual Basic 2005 application to communicate with an
I2C device. I recently decided to add an i2c status bar. The status
bar is just a textbox with the following properties:

When I2C communication active:
Public Sub i2c_active()
statusBar.Text = "Exchanging Data..."
statusBar.BackColor = Drawing.Color.Red
End Sub

When I2C communication is idle:
Public Sub i2c_idle()
statusBar.Text = "IDLE"
statusBar.BackColor = Drawing.Color.Lime
End Sub

Ideally, the above properties are changed before and after the
get_i2c_data function. For example:
i2c_active()
get_i2c_data()
i2c_idle()

The problem is that the textbox properties for i2c_active() don't
change until after the get_i2c_data() function finishes. For example,
if I execute
i2c_active()
get_i2c_data()
the textbox doesn't turn red and display "Executing Data..." until
after it has already retrieved the data from the i2c device. This is
completely pointless!

There is some sort of delay between when the i2c_active() function
executes and when I see the textbox properties change. To debug, I
tried just executing the i2c_active() function and the textbox
properties change instantaneously. I need to have the textbox
properties change instantaneously when the get_i2c_data() function is
included. I'm not sure how to get this working. Any suggestions
would be appreciated.
More than likely, the i2c_data method is blocking the UI thread so it
cannot process messages. One quick solution would be to add
statusBar.Refresh() after you change the text and color.

If that doesn't work, you may wish to move the processing of the
i2c_data code to a separate thread.

Chris

Aug 30 '07 #2
Although the "active()" function modifies the properties of the text box, it
won't get repainted until the function has exited and windows pumps its
message queue. You could try using the Refresh () method to force a paint
immediately after active().
Aug 30 '07 #3
<we***@drexel.eduwrote in message
news:11**********************@q5g2000prf.googlegro ups.com...
Hi all,

I'm developing a Visual Basic 2005 application to communicate with an
I2C device. I recently decided to add an i2c status bar. The status
bar is just a textbox with the following properties:

When I2C communication active:
Public Sub i2c_active()
statusBar.Text = "Exchanging Data..."
statusBar.BackColor = Drawing.Color.Red
End Sub

When I2C communication is idle:
Public Sub i2c_idle()
statusBar.Text = "IDLE"
statusBar.BackColor = Drawing.Color.Lime
End Sub

Ideally, the above properties are changed before and after the
get_i2c_data function. For example:
i2c_active()
get_i2c_data()
i2c_idle()

The problem is that the textbox properties for i2c_active() don't
change until after the get_i2c_data() function finishes. For example,
if I execute
i2c_active()
get_i2c_data()
the textbox doesn't turn red and display "Executing Data..." until
after it has already retrieved the data from the i2c device. This is
completely pointless!

There is some sort of delay between when the i2c_active() function
executes and when I see the textbox properties change. To debug, I
tried just executing the i2c_active() function and the textbox
properties change instantaneously. I need to have the textbox
properties change instantaneously when the get_i2c_data() function is
included. I'm not sure how to get this working. Any suggestions
would be appreciated.

Thanks,
-weg22

Application.DoEvents() inserted between the calls should update the textbox
prior to entering the second subroutine (If we are talking the same
language - I get confused over variations:)

--
regards,
Les Hay, Livingston, Scotland

Aug 30 '07 #4
statusBar.Refresh() worked!!! Thank you very much.
Aug 30 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: lucifer | last post by:
hi i need to insert delay in my program what function should i use the old delay is not supported by the VC6
4
by: Tony W | last post by:
Hi, I am trying to write a simple application to retrieve data from the Windows registry and insert it into textboxs on a windows form. So far I have one namespace containing two classess. ...
4
by: Jeremy S | last post by:
I have written an ASP.NET application that performs very well. I make heavy use of the Cache and otherwise minimize the number of round trips to to the db. I couldn't be happier with the...
2
by: Uveper | last post by:
I am trying to create a textbox which would have a delayed input from keyboard. For example when I press "A" it waits for 200 ms and only after that time it passes the key to textbox. I tryed to do...
2
by: Peter Rilling | last post by:
I have controls on a page such as a textbox where I would like the font to match the rest of the page. The CSS style applied to the <body> tag does not seem to be used by the textbox. Can the...
2
by: WhatHappend | last post by:
I have converted a .Net 1.0 application to .Net 2.0 and the web service invocations have delay of around 10seconds on each intial access. After the first access subsequent access are fast (After a...
13
by: WALDO | last post by:
I have a .Net TextBox (TextBoxBase, really) in which I am appending about 20 lines of text per second. I use the AppendText() method to accomplish this. This is a great substitute for taking the...
10
by: engteng | last post by:
When textbox properties enable = False the font in the textbox become gray color. How do I change the gray color to black color ? Regards, Tee
3
Raventara
by: Raventara | last post by:
Hi all, I have a program which will routinely update the image of a picturebox and resize the picturebox to keep the aspect ratio of the image in tact. The problem I am having is that after about...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.