Re: Threading

From: Brian P. Hammer (bphammer_at_email.uophx.edu)
Date: 06/02/04


Date: Wed, 2 Jun 2004 00:07:24 -0500

Chris - Thanks for the pointer. Sorry, but I am kind of new to this whole
concept. If I call from my main thread:

Dim dlgt As New AsyncDelegate(AddressOf ManufacturerData)
Dim ar As IAsyncResult = dlgt.BeginInvoke(Nothing, Nothing)

Private Function ManufacturerData() as String 'The new thread
'Do my SQL connection here
'....
'....
'....
Do While drSQL.Read()
objManufacturerItem = New
ListItem(drSQL.Item("ManufacturerName").ToString(), _
CInt(drSQL.Item("IDManufacturer")))
'Cross thread issue here
Me.cboManufacturer.Items.Add(objManufacturerItem)
Loop
'....
'....
End Sub

Is this doing what I need?

Thanks,
Brian P. Hammer

"Christopher Kimbell" <a@b.c> wrote in message
news:40badcef$1@news.broadpark.no...
You are correct. GUI elements can only be accessed on the GUI thread. What
you have to do is to execute code on the UI thread from some other thread.
Each control has a InvokeRequired property and Invoke method, the former
indicating if the latter must be called.

Here is an article that describes the problem with code:

http://weblogs.asp.net/justin_rogers/articles/126345.aspx

Chris

"Brian P. Hammer" <bphammer@email.uophx.edu> wrote in message
news:%23rHCdYtREHA.1312@TK2MSFTNGP12.phx.gbl...
All - I have the need to make my app multi threaded for those long running
tasks. Some of them are not a problem but the question I have is with SQL
and populating items on a form. If I create a new thread, connect to my SQL,
run a long query and then populate a combobox within this new thread; I am
guessing I should not do this. Somewhere I read that items created on one
thread should not be manipulated on another.

How does one go about doing this? I have read through the help and examples
but didn't see anything that jumped out as an answer.

Thanks,
Brian P. Hammer



Relevant Pages

  • Re: Are split databases a chimera of utility?
    ... reading tutorials about access and SQL and learned more than my boss, ... Chris, ... Not in SQL Server, not in mysql, not in Oracle, not even in Access. ... the db, speed for developers in development and maintenance, exclusive access ...
    (microsoft.public.access.tablesdbdesign)
  • Re: PHP and secure MySQL injections
    ... Chris Hope wrote: ... >> I don't think My SQL will do that anyway. ... I then used what was in the error message (which contained the full ... as I just ran another test for semi-colons ...
    (comp.lang.php)
  • Re: XML XPath Query compact framework
    ... Thanks Chris - I had a feeling that might be the case... ... >> the relevant sql element out of the XML and returning it as a string. ... >> are XPath node selections done in the CF? ... > There is no XPath support on the CF. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Serializing PreparedStatement, or: how do create a database history?
    ... Look at the disconnected JDBC RowSet: ... Chris wrote: ... > executed on the database (SQL select is not needed). ... > As this is an extension to an existing program, and PreparedStatement is ...
    (comp.lang.java.databases)