By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,679 Members | 1,443 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,679 IT Pros & Developers. It's quick & easy.

threading question about focus

P: n/a
OK, I have an app that when it loads, it calls a sub which loads a dataset
from a web service. I spin the call on another thread so the user doesn't
get an unresponsive screen. The problem ensues when the web service can't
be contacted (which is OK). I throw up a messagebox to the user and an
opendialog control, but since this is happening on another thread, the user
can still do activity in the main form.

I suppose this breaks a tenent of why you're doing threading in the first
place, but can someone offer a suggestion anyway?

Code goes like this
' Spin the dataset filling to a new thread
Dim ts As New ThreadStart(AddressOf FillDataSetFromWebService)
Dim t As New Thread(ts)
t.Name = "FillDataSetFromWebService"
t.Start()

thanks,
Eric
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Do Async Callbacks... Let it know when its done or something happened.

-CJ
"Eric Sabine" <mo*****@hyottmail.com> wrote in message
news:3f***********************@news.twtelecom.net. ..
OK, I have an app that when it loads, it calls a sub which loads a dataset
from a web service. I spin the call on another thread so the user doesn't
get an unresponsive screen. The problem ensues when the web service can't
be contacted (which is OK). I throw up a messagebox to the user and an
opendialog control, but since this is happening on another thread, the user can still do activity in the main form.

I suppose this breaks a tenent of why you're doing threading in the first
place, but can someone offer a suggestion anyway?

Code goes like this
' Spin the dataset filling to a new thread
Dim ts As New ThreadStart(AddressOf FillDataSetFromWebService)
Dim t As New Thread(ts)
t.Name = "FillDataSetFromWebService"
t.Start()

thanks,
Eric

Nov 20 '05 #2

P: n/a
"Eric Sabine" <mo*****@hyottmail.com> schrieb
OK, I have an app that when it loads, it calls a sub which loads a
dataset from a web service. I spin the call on another thread so the
user doesn't get an unresponsive screen. The problem ensues when the
web service can't be contacted (which is OK). I throw up a
messagebox to the user and an opendialog control, but since this is
happening on another thread, the user can still do activity in the
main form.

I suppose this breaks a tenent of why you're doing threading in the
first place, but can someone offer a suggestion anyway?

Code goes like this
' Spin the dataset filling to a new thread
Dim ts As New ThreadStart(AddressOf FillDataSetFromWebService)
Dim t As New Thread(ts)
t.Name = "FillDataSetFromWebService"
t.Start()


If you want the message to appear in the main UI thread, the call must be
marshalled by calling the main form's Invoke method. See the method's
description for more information. Also:

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB/vbcn7/html/vaconFreeThreadingWithF
ormsControls.htm

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB/cpguide/html/cpcondevelopingmultit
hreadedwindowsformscontrol.htm

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB/dnforms/html/winforms08162002.htm

(see hints in signature)

--
Armin

- Links might be split into two lines. Concatenate them using notepad.
- Links might require to add a ".nnnn" after the "2003FEB", e.g.
"2003FEB.1033" for localized versions.
- Links starting with "ms-help" are URLs for the document explorer (<F1>).
Paste them in the URL textbox and press enter. Using internal help (menu
tools -> options -> environment -> help), display the "Web" toolbar that
contains the textbox.
Nov 20 '05 #3

P: n/a
Thanks Armin & CJ. Perhaps its obvious that this is new to me. Those links
will help, also I'm going to look for some whitepapers/tech articles on the
subject.

Eric

"Armin Zingler" <az*******@freenet.de> wrote in message
news:Ou**************@TK2MSFTNGP12.phx.gbl...
"Eric Sabine" <mo*****@hyottmail.com> schrieb
OK, I have an app that when it loads, it calls a sub which loads a
dataset from a web service. I spin the call on another thread so the
user doesn't get an unresponsive screen. The problem ensues when the
web service can't be contacted (which is OK). I throw up a
messagebox to the user and an opendialog control, but since this is
happening on another thread, the user can still do activity in the
main form.

I suppose this breaks a tenent of why you're doing threading in the
first place, but can someone offer a suggestion anyway?

Code goes like this
' Spin the dataset filling to a new thread
Dim ts As New ThreadStart(AddressOf FillDataSetFromWebService)
Dim t As New Thread(ts)
t.Name = "FillDataSetFromWebService"
t.Start()
If you want the message to appear in the main UI thread, the call must be
marshalled by calling the main form's Invoke method. See the method's
description for more information. Also:

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB/vbcn7/html/vaconFreeThreadingWithF ormsControls.htm

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB/cpguide/html/cpcondevelopingmultit hreadedwindowsformscontrol.htm

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB/dnforms/html/winforms08162002.htm
(see hints in signature)

--
Armin

- Links might be split into two lines. Concatenate them using notepad.
- Links might require to add a ".nnnn" after the "2003FEB", e.g.
"2003FEB.1033" for localized versions.
- Links starting with "ms-help" are URLs for the document explorer (<F1>).
Paste them in the URL textbox and press enter. Using internal help (menu
tools -> options -> environment -> help), display the "Web" toolbar that
contains the textbox.

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.