Thread blocking

dermjs

New member
Joined
Jun 23, 2004
Messages
1
Programming Experience
10+
Hello,

I've got this problem and I'm not sure where to post it or how to fix it. I think the problem has to do with thread blocking. Anyway...

I have this program that is a record management type of program. It uses a web service and threading. The program keeps a history of all the records that were entered into it and changed.

What the program is doing... When the program is open, it generally allows the user to create new records and edit new records among other things. However, the program has timers that at specific interval are coded to retrieve database information. When these timers run, the application "freezes"... the user cannot click on any records, edit any records, or create any records until the database information has been retrieved into the program. This happens every 3 to 5 mins and the app freezes for 30 seconds or so. The application also freezes when a record is inserted or updated. Does this sound like a threading problem? If so, how can I fix it? Are there any good examples for threading?

Thanks.
Heather
 

edd1em

Active member
Joined
Jul 21, 2004
Messages
28
Programming Experience
3-5
Its simple really....err not really.

Here is some code, I had the same problem. My users use this app to connect remotely to sql server.

So at the begining I load all of the tables in memory, takes about 40, it runs on its own thread, so I have the splash screen with a progressbar, that just goes round-n-round until its done.

But the example that I will show is the delete process. When I delete, I delete from memory and then send the delete command to sql server on a separate thread, it might not be in that particular order...

Well without further ado, here is the code:
Private Sub Deleter()
On Error GoTo Error_Handler


'Throw Delete Function on an asynchronous thread
t1 = New Thread(AddressOf DeleteSource)
t1.Start()


'Remove the record from the memory table
frmTurbo.DataSet.Tables(dtName).Rows.RemoveAt(Row)
GridDataRefresh()
frmTurbo.blInsuranceSave = False
Exit Sub


Error_Handler:
blah blah blah
Exit Sub
End Sub


Private Sub DeleteSource()
Dim strInsVal As String = "DELETE FROM " & dtName & " WHERE ("


strInsVal += frmTurbo.DataSet.Tables(dtName).Columns(intCol).ColumnName.ToString & " = '" & arrRow(intCol) & "'"
strInsVal += ")"


'Delete Record
GetRecords(strInsVal, "Delete", dtName)


End Sub


 
Top Bottom