The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024


[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

RE: VB 2005 express



I encountered this same problem when moving some of my xPL code across to
VB2005 - the UI thread and the background thread are more isolated now: the
impression I get from reading various articles is that .net was pretty much
always supposed to be this way, but it was only a warning in the past -
which lead to people taking the chance that it would work 99% of the time.

Now it's rock solid, you have to use delegates - I declare something like
this:

Public Delegate Sub SetLabel(ByVal [text] As String)

At the top of the class, then declare this sub in the body:

Private Sub SetLabel(ByVal strNewLbItem As String)
If Me.lblTextLabel.InvokeRequired Then
Dim d As New SetLabel(AddressOf SetLabel)
Me.lblTextLabel.Invoke(d, New Object() {strNewLbItem})
Else
lblTextLabel.Text = strNewLbItem
End If
End Sub

When I would normally just so a straight assignment, I instead do:

Setlabel("somevalue")

It might not be perfect, but it works nicely for me :)

Ian.


-----Original Message-----
From: ukha_d@xxxxxxx [mailto:ukha_d@xxxxxxx] On Behalf Of
Dave Sussman
Sent: 15 December 2005 16:37
To: ukha_d@xxxxxxx
Subject: RE: [ukha_d] VB 2005 express

I'm not a winform developer so probably can't help much. However, I do know
that you can only update the UI from the UI thread, so it sounds like
you've
got a background thread doing the monitoring. If so, you need to use
delegates or the BackgroundWorker component, to marshal the data to be
displayed to the UI. Unfortunately I know nothing about how to actually
implement this, but a quick google should help point you in the right
direction.



d



________________________________

From: ukha_d@xxxxxxx [mailto:ukha_d@xxxxxxx] On Behalf Of
Paul Smith
Sent: 15 December 2005 16:29
To: ukha_d@xxxxxxx
Subject: [ukha_d] VB 2005 express



Hi Guys,



Anyone here using VB 2005, I'm rather new to this. I used
vb6 to build 2 apps which monitor the pins on a serial port to record the
flashes from my electric meter. However due to a hard disk failure I have
lost vb6 and all the code I wrote. So I have download vb 2005 express and
am
trying to get this to do the same as I now have a water meter which will
pulse for each litre. I could do with some help as this is a very basic app
but I get an error which I don't under stand.



With in the event trigger by a pin changing on the serial port should
update
a text box on the form, but I get and error saying I can't do this as the
thread is not the one the form was created by. Can anyone shed some light
on
this.



I can send over the code it that would help.





Regards,



Paul





[Non-text portions of this message have been removed]








SPONSORED LINKS

Home repair improvement
<http://groups.yahoo.com/gads?t=ms&k=Home+repair+improvement&w1=Home+rep
air+improvement&w2=Computer+stuff&w3=High&w4=Improvement&c=4&s=76&.sig=T
cERUCDPQcJLbg9mtvQGJQ>

Computer stuff
<http://groups.yahoo.com/gads?t=ms&k=Computer+stuff&w1=Home+repair+impro
vement&w2=Computer+stuff&w3=High&w4=Improvement&c=4&s=76&.sig=plS9-eUUfa
BXyLVFT87AJg>

High
<http://groups.yahoo.com/gads?t=ms&k=High&w1=Home+repair+improvement&w2=
Computer+stuff&w3=High&w4=Improvement&c=4&s=76&.sig=b5d547gPx7eFWNGqXQCl
7A>

Improvement
<http://groups.yahoo.com/gads?t=ms&k=Improvement&w1=Home+repair+improvem
ent&w2=Computer+stuff&w3=High&w4=Improvement&c=4&s=76&.sig=O6pw_oratTOwe
p2G_91fIQ>







________________________________

YAHOO! GROUPS LINKS



*	 Visit your group "ukha_d <http://groups.yahoo.com/group/ukha_d>
" on the web.

*	 To unsubscribe from this group, send an email to:
ukha_d-unsubscribe@xxxxxxx
<mailto:ukha_d-unsubscribe@xxxxxxx?subject=Unsubscribe>

*	 Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service <http://docs.yahoo.com/info/terms/>
.



________________________________



[Non-text portions of this message have been removed]




UKHA_D Main Index | UKHA_D Thread Index | UKHA_D Home | Archives Home

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.