Newbie on Threads!

  • Thread starter Thread starter Lars Netzel
  • Start date Start date
L

Lars Netzel

Hello!

If i have an operation I want to place in a separate thread to make things a
little faster how do I do it?

Let's say this Filling of a Dataset takes a long time

DataAdapter.Fill(dsData)

How can I write it so I use another thread ?

regards
/Lars
 
Hi,
Check out the System.Threading namespace.

Hello!

If i have an operation I want to place in a separate thread to make things a
little faster how do I do it?

Let's say this Filling of a Dataset takes a long time

DataAdapter.Fill(dsData)

How can I write it so I use another thread ?

regards
/Lars
 
Hi Lars,

Using threads makes the total processing time of your application longer.
It can influence the througput of your processing.

That is when there is a proces that waits on an action while there is
another process that can go on in that time.

Normally that is not in the situation of filling a single dataset, mostly
you needs that data to take the next actions.

While with a dataset there is probably one database server so splitting that
up will also not give any benefit in my opinion by using more datasets.

However when you have datasets from seperate database servers than it can
maybe speed it up.

Just a splash form as showed in the resource kit is in my idea enough for
that.

I hope this gives some ideas?

Cor
 
Hi,

Like Cor says this will not make the data fill any faster it will
just do it in the background.

http://msdn.microsoft.com/msdnmag/issues/03/12/CriticalSections/default.aspx

http://msdn.microsoft.com/msdnmag/issues/04/05/BasicInstincts/

Dim thrSlowProcedure As New Threading.Thread(AddressOf GetColumnNames)

thrSlowProcedure.Start()



Private Sub GetColumnNames()

Dim strConn As String

Dim strSQL As String

Dim conn As OleDbConnection

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"

strConn &= "Data Source = Northwind.mdb;"

conn = New OleDbConnection(strConn)

conn.Open()

Dim dtTableNames As DataTable

dtTableNames = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, _

New Object() {Nothing, Nothing, Nothing, "TABLE"})

conn.Close()

Dim dr As DataRow

For Each dr In dtTableNames.Rows

Trace.WriteLine(dr.Item("TABLE_NAME"))

Next

End Sub



Ken

-------------------------------

Hello!

If i have an operation I want to place in a separate thread to make things a
little faster how do I do it?

Let's say this Filling of a Dataset takes a long time

DataAdapter.Fill(dsData)

How can I write it so I use another thread ?

regards
/Lars
 
okay.. it makes since.. then I don't really have any sitiatuions in my
porgram where this will be nedeed

and I tested and I did'nt really feel any differance!

/lars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top