Thread issue ??

  • Thread starter Thread starter Tlink
  • Start date Start date
T

Tlink

I have a master control program that needs to run continuously, accepting
data and updating a datagrid for the user. As a result I have setup 2
threads, one accepts and processes incoming requests and updates the
database, whilst the other thread is started once a update has been
committed to the database. The problem is when the datagrid is accessed
after the first time it is unable to access the datagrid (Cannot clear this
list)?

I have delegated the threads and also checked and invoked the thread as
below: The listenthread functions without issue as it never stops running,
whilst the tableupdate thread terminates when no vieweable data alters. Any
help or guidance would be greatly appreciated.

Delegate Sub CreateDataSourceCallBack()
Private ThreadListen As New Thread(AddressOf ListenServerThread)
Private ThreadTableUpdate As New Thread(AddressOf CreateDataSource)
*** wrapped in a try ***

If Me.DGV1.InvokeRequired = True Then
Dim invoke_createdatasource As New CreateDataSourceCallBack(AddressOf
CreateDataSource)
Me.Invoke(invoke_createdatasource)
Else
Me.DGV1.Rows.Clear()
update grid here.......

I reset the thread to update the table as listed below:
If ThreadTableUpdate.ThreadState = ThreadState.Stopped Then
Me.ThreadTableUpdate = New Thread(New ThreadStart(AddressOf
Me.CreateDataSource))
Me.ThreadTableUpdate.Start()
End If
 
Tlink,


It looks if you try to create a connected application using a Dataset. If
you are updatating the datasource of you cannot in the same time refill
that. It has to be one by one and needs too time time, that your user is
able to do as well things. You are pulling on four sides of the datagrid.
(Filling, updating from it by the database, Reading by the user, updating by
the user). This kind of operations are and stay forever serial and are not
parallel. (Although they can exist in any sequence as is needed).

Just my thought reading your message.

Cor
 
I am unsure as to your response, what I am doing perhaps explained:

One thread that updates the database

One thread that reads the database and updates the datagrid

Does this help, as I am still confused?
 
Tlink,

What I want to say, is that the use of threads has in my opinion absolute no
sense.

The processes are complete serialized, so threads gives you only overhead
and trouble.

Cor
 
Back
Top