troubleshooting Question Creating threads for SQL query and GIF

Avatar of jamesspo
jamesspo asked on
.NET ProgrammingVisual Basic.NET
3 Comments1 Solution999 ViewsLast Modified:
Hi Experts.
(using, Visual studio 2005 Pro)
I'm really not sure why I cannot make this work. I  have a windows form (form1) which contains (not surprisingly) contains functions and subs. On a tab I have a groupBox containing a button, label and pictureBox.

Like many who have gone before me, I would like to show an animated GIF next to the button in the groupBox while a long (1-2 minites) SQL query executes.

class form1
   Private Sub btnUpdate_Click(ByVal sender...)
end class

if we assume that the btnUpdate_Click event which triggers the following code;
Private Sub btnUpdate_Click(ByVal sender...)
   connect to database
   run large "SELECT INTO" command
end sub

How do I thread the sql query and the gif to make both run at the same time??

I have tried
1) Creating 2 threads at the start of the form1 class, then calling them for a sub which updates the database and another sub the displays the gif.
2) Creating 1 thread for form1, in which the gif is placed and another thread for the SQL query sub

Neither work. I get cross-threading errors (Visual studio 2005). I'm using the following commands.

Dim thdSQL As Thread
thdSQL = New Thread(AddressOf updateSQL)
thdSQL .Start()

Can anyone suggest exactly how I run the SQL "SELECT INTO" and "animated gif" in different threads so that I get the desired effect?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros