12 Replies - 597 Views - Last Post: 07 August 2013 - 08:53 AM Rate Topic: -----

#1 HeBTeMy  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 299
  • Joined: 05-October 12

Update UI from thread error

Posted 03 August 2013 - 03:33 PM

Hi, i'm using this code to start a new thread:
 Dim t As New System.Threading.Thread(AddressOf externalIP)
        t.Start()



It connects to whatismyip to retrieve the external ip for my app wich collects every PC information i can.
The thing is, if i try to update the UI from the thread, it throws me an error, and i need to update it from the thread.
Any help?

I read online about having to invoke the thread or something but i can't understand.

Thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: Update UI from thread error

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,057
  • Joined: 02-July 08

Re: Update UI from thread error

Posted 03 August 2013 - 05:19 PM

You need a delegate in the externalIP sub. Threads are not on the UI thread. My delegate is a Sub inside a sub rather than an external sub that handles the UI update.

Private Sub externalIP()
   Me.Invoke(Sub() 
                'do UI updating in here
             End Sub)
End Sub

This post has been edited by _HAWK_: 03 August 2013 - 05:21 PM

Was This Post Helpful? 1
  • +
  • -

#3 HeBTeMy  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 299
  • Joined: 05-October 12

Re: Update UI from thread error

Posted 03 August 2013 - 05:33 PM

View Post_HAWK_, on 03 August 2013 - 05:19 PM, said:

You need a delegate in the externalIP sub. Threads are not on the UI thread. My delegate is a Sub inside a sub rather than an external sub that handles the UI update.

Private Sub externalIP()
   Me.Invoke(Sub() 
                'do UI updating in here
             End Sub)
End Sub


Thanks ! It worked.

Cheers.
Was This Post Helpful? 0
  • +
  • -

#4 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,057
  • Joined: 02-July 08

Re: Update UI from thread error

Posted 03 August 2013 - 06:05 PM

;)
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8937
  • View blog
  • Posts: 33,463
  • Joined: 12-June 08

Re: Update UI from thread error

Posted 03 August 2013 - 10:08 PM

View PostHeBTeMy, on 03 August 2013 - 05:33 PM, said:

Hi, i'm using this code to start a new thread:
 Dim t As New System.Threading.Thread(AddressOf externalIP)
        t.Start()



It connects to whatismyip to retrieve the external ip for my app wich collects every PC information i can.
The thing is, if i try to update the UI from the thread, it throws me an error, and i need to update it from the thread.
Any help?

I read online about having to invoke the thread or something but i can't understand.

Thank you.

Grab the PC's external IP and "every PC information i can"? ... sounds.. odd.
Was This Post Helpful? 0
  • +
  • -

#6 HeBTeMy  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 299
  • Joined: 05-October 12

Re: Update UI from thread error

Posted 04 August 2013 - 02:34 PM

No, it's PC information collect for personal use and knowledge, like screen resolution, amount of RAM, disk space, OS bits and stuff, not like personal information.

This post has been edited by andrewsw: 04 August 2013 - 02:50 PM
Reason for edit:: Removed previous quote

Was This Post Helpful? 0
  • +
  • -

#7 AdamSpeight2008  Icon User is online

  • MrCupOfT
  • member icon


Reputation: 2240
  • View blog
  • Posts: 9,411
  • Joined: 29-May 08

Re: Update UI from thread error

Posted 04 August 2013 - 04:33 PM

Why?
Was This Post Helpful? 0
  • +
  • -

#8 HeBTeMy  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 299
  • Joined: 05-October 12

Re: Update UI from thread error

Posted 04 August 2013 - 06:25 PM

Because it's useful?
Was This Post Helpful? 0
  • +
  • -

#9 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 966
  • Joined: 09-May 09

Re: Update UI from thread error

Posted 05 August 2013 - 01:50 AM

don't think your going to obtain an explanation on this one Adam :)
Was This Post Helpful? 0
  • +
  • -

#10 HeBTeMy  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 299
  • Joined: 05-October 12

Re: Update UI from thread error

Posted 05 August 2013 - 04:39 AM

View Postdeery5000, on 05 August 2013 - 01:50 AM, said:

don't think your going to obtain an explanation on this one Adam :)/>


I can't understand why an explanation is needed, almost every app obtains your IP address, or uses it, obtains your username, computername and such, i'm still a beginner, i want to learn how to obtain that, using vb.net itself.
I think that's useful, if you don't or think otherwise it's up to you.
And it's useful for every single app as i stated, knowing the root directory of system like in most is "C:\" but it is not mandatory and could cause problems, it's just, good principles in coding in my opinion to prevent errors.
Was This Post Helpful? 0
  • +
  • -

#11 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 966
  • Joined: 09-May 09

Re: Update UI from thread error

Posted 07 August 2013 - 07:33 AM

There is no need to get defensive . . . as developers we question why and how things are done on a daily basis

So asking WHY you would require this information is harmful, if your developing an application that utilises this information then you can share unless you wish to keep it a secret.

In that case a simple comment stating you do not wish to disclose the details of the application is sufficient.

Just remember that you are asking for help . . . . u don't want to piss off the guys with 8k+ posts
Was This Post Helpful? 0
  • +
  • -

#12 HeBTeMy  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 299
  • Joined: 05-October 12

Re: Update UI from thread error

Posted 07 August 2013 - 08:31 AM

View Postdeery5000, on 07 August 2013 - 07:33 AM, said:

There is no need to get defensive . . . as developers we question why and how things are done on a daily basis

So asking WHY you would require this information is harmful, if your developing an application that utilises this information then you can share unless you wish to keep it a secret.

In that case a simple comment stating you do not wish to disclose the details of the application is sufficient.

Just remember that you are asking for help . . . . u don't want to piss off the guys with 8k+ posts


I offcorse won't disclose no one's information.
But, don't think this information is that harmful, as it can be easily obtained with no special priviledges or stuff, ofcourse i'm not distributing people's information...
I could already obtain what i needed, i just wanted to do it in a new thread updating the UI (wich is for users to see ofcourse), wich i've never done before.
I'm not here to piss off anyone, just trying to help and help if needed.

Thanks all, ;)
Was This Post Helpful? 0
  • +
  • -

#13 deery5000  Icon User is offline

  • D.I.C Addict

Reputation: 78
  • View blog
  • Posts: 966
  • Joined: 09-May 09

Re: Update UI from thread error

Posted 07 August 2013 - 08:53 AM

Thank you for the update
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1